The Mathematics of Tower of Hanoi: History, Recurrence & Strategy
Invented in 1883 by French mathematician รdouard Lucas, the Tower of Hanoi is one of the most famous recursive puzzles in computer science and mathematics. Lucas framed the puzzle around an ancient legend: in an Indian temple at Benares, priests transfer 64 golden disks across three diamond needles. According to the prophecy, when the last disk is transferred, the world will end.
The Golden Formula: 2n − 1
The minimum number of moves to transfer (n) disks is governed by the recursive equation:
T(n) = 2 × T(n - 1) + 1 = 2n − 1
- 3 Disks: 23 − 1 = 7 moves
- 4 Disks: 24 − 1 = 15 moves
- 5 Disks: 25 − 1 = 31 moves
- 6 Disks: 26 − 1 = 63 moves
- 64 Disks: 18,446,744,073,709,551,615 moves (approx. 585 billion years at 1 move per second)!
Recursive Algorithm
To move (n) disks from Source peg (A) to Destination peg (C) using Auxiliary peg (B):
- Move (n - 1) disks from (A) to (B) using (C).
- Move the largest disk ((n)) directly from (A) to (C).
- Move the (n - 1) disks from (B) to (C) using (A).