How it works
Rules
- Start with n disks stacked on one peg, largest at the bottom and smallest on top.
- Move the whole ordered stack to a designated destination peg; the remaining peg is the auxiliary (spare).
- Move only one disk at a time: take the top disk of a peg and place it on another peg.
- Never place a larger disk on a smaller disk—only on an empty peg or on a strictly larger disk.
- On three pegs the minimum number of moves is exactly (2^n - 1).
Allowed moves
| Action | Rule |
|---|---|
| Lift top disk | Allowed; only the uppermost disk on a peg may move |
| Place on empty peg | Allowed |
| Place on larger disk | Allowed |
| Place on smaller disk | Forbidden |
| Move several disks together | Forbidden |
| Lift a buried disk | Forbidden |
Illegal attempts (larger onto smaller, or non-top disk) must be rejected with clear feedback; the board state does not change.
How to play
- Choose n (beginners: 3; standard practice: 4–5; classic toys often 5–8).
- Mark start peg and goal peg; the third peg is spare.
- Move disks one by one under the size rule.
- Recursive strategy for an optimal solve: move the top (n-1) disks to the spare, move the largest disk to the goal, then move the (n-1) stack onto the goal.
- Finish when every disk sits on the goal peg in size order. Hitting (2^n - 1) moves is an optimal solve.
Board, pieces, and n
| Element | Count / role |
|---|---|
| Pegs (rods) | 3 in the classic game |
| Disks | n, each a different diameter, center hole for the peg |
| Start stack | All n on the start peg, large → small upward |
| Goal | Same ordered stack on the destination peg |
| n | Minimum moves (2^n-1) |
|---|---|
| 1 | 1 |
| 2 | 3 |
| 3 | 7 |
| 4 | 15 |
| 5 | 31 |
| 6 | 63 |
| 8 | 255 |
| 64 | (2^{64}-1) (legend scale) |
The rule focus is the size constraint and the (2^n-1) optimum—not free stacking without the “never larger on smaller” law.
Play modes
| Mode | What you see | Goal |
|---|---|---|
| Classic transfer | Three pegs, fixed n | Rebuild the stack on the goal peg |
| Optimal challenge | Move counter + target (2^n-1) | Finish in exactly the minimum |
| Free practice | Same board, no move cap | Explore legal sequences |
| Multi-peg (advanced) | Four or more pegs | Variants such as Reve’s puzzle; outside the classic three-peg syllabus |
You can also play the Tower of Hanoi online.
Development History
(1) Lucas’s 1883 product
The Tower of Hanoi entered print and commerce in Paris in 1883. French mathematician Édouard Lucas marketed a boxed peg-and-disk game under the playful pseudonym “N. Claus (de Siam),” an anagram of “Lucas d’Amiens.” The label’s “College of Li-Sou-Stian” is likewise an anagram of the Lycée Saint-Louis, where Lucas taught. Surviving boxes and instruction leaflets—documented by the Puzzle Museum and by Paul Stockmeyer’s transcriptions—show a Tonkin / Hanoi framing that matched contemporary French interest in Indochina. That packaging is marketing geography, not evidence that Lucas had recovered an archaeological object from Vietnam.
(2) The Benares legend as product folklore
The leaflet accompanying the game told a legend: beneath a temple dome in Benares (Varanasi), Brahmins move sixty-four golden disks among three diamond needles under the same size rule; when the last disk is placed, the tower, the priests, and the world end. Variants relocate the temple or rename the priests, but the exponential punch line is constant: (2^{64}-1) moves. Treat the story as packaging folklore that dramatizes growth. It is not independent evidence that a mechanical Tower of Hanoi existed in ancient India. MacTutor and modern surveys state the same caution: Lucas invented the documented puzzle; the Indian setting is attached legend.
(3) Recreational mathematics and recursive popularization
Lucas collected such diversions in Récréations mathématiques (and related booklets). The three-peg solution became a textbook illustration of recursion and mathematical induction: to move n disks, move (n-1) to the spare peg, move the largest disk once, then move (n-1) onto the goal. The closed form (T(n)=2^n-1) follows at once. Later popularizations linked optimal play to binary counting and Gray codes: the disk moved at step k and the parity of peg visits can be read from bit flips. Martin Gardner’s mid-century essays helped fix the puzzle in Anglophone recreational math; MathWorld and discrete-math courses still present it as the canonical exponential-recursion example.
(4) Reve’s puzzle and multi-peg research
A four-peg relative appears in Henry Ernest Dudeney’s early-twentieth-century work as the Reve’s puzzle (cheeses moved among stools). Extra pegs break the simple (2^n-1) formula. In 1941 Frame and Stewart proposed recursive schemes for r pegs that became the presumed-optimal Frame–Stewart family; for decades optimality for four pegs remained open, though the algorithm was widely taught. Thierry Bousch proved Frame–Stewart optimal for four pegs in 2014. Everyday “Tower of Hanoi” still means the classic three-peg game; Reve’s puzzle is a sibling, not a replacement.
(5) Cultural use in computer-science teaching
From the mid-twentieth century onward, introductory programming and algorithms courses adopted the three-peg Tower of Hanoi as a first recursive procedure: base case one disk; inductive step two recursive calls plus one move. Lecturers use it to contrast elegant recursion with the concrete cost (2^n-1), to motivate induction proofs, and sometimes to encode move sequences with binary or Gray-code tricks. Physical classroom kits and online applets keep the same rule set Lucas sold in 1883. The legend of sixty-four disks remains a vivid way to say “exponential growth,” not a claim about temple archaeology.
References
- MacTutor History of Mathematics, The Towers of Hanoi
- Puzzle Museum, Eduardo Lucas: La Tour D’Hanoi (1883 box & leaflet)
- Paul K. Stockmeyer, The Tower of Hanoi (original instructions & bibliography)
- Wolfram MathWorld, Tower of Hanoi
- English Wikipedia, Tower of Hanoi
- Andreas M. Hinz, “The Tower of Hanoi,” 1989 (e-periodica scan)
- Hinz et al. / Stockmeyer survey material on multi-peg variants
Geography and timeline
- 1883FranceOrigin in FranceOrigin claimConfidence: High
Édouard Lucas introduced the documented Tower of Hanoi in Paris in 1883.
- The Towers of HanoiMacTutor documents Lucas’s Paris introduction in 1883.
- 1883FranceFrench commercializationCommercialized inConfidence: High
The puzzle and its accompanying leaflet were marketed in France in 1883.
- Eduardo Lucas: La Tour D’HanoiThe surviving product and leaflet support 1883 commercialization.
- 1883IndiaLegendary Indian associationCultural associationConfidence: High
The 1883 product attached a Benares Brahmin legend to the puzzle; this is not evidence of ancient Indian origin.
- The Towers of HanoiMacTutor documents the Indian temple story as an attached legend.
FAQ
What is the Tower of Hanoi?
A peg-and-disk puzzle: move a stack of different-sized disks from one peg to another, one top disk at a time, never placing a larger disk on a smaller one. The classic game uses three pegs. It is not “stack anything anywhere”—the size rule is mandatory.
What are the forced rules?
(1) Only the top disk of a peg may move. (2) A disk may land only on an empty peg or on a strictly larger disk. (3) The whole ordered stack must end on the destination peg. Breaking the size rule is an illegal move and must be refused.
What is the minimum number of moves?
For n disks on three pegs the minimum is (2^n - 1): 3 disks → 7 moves, 4 → 15, 5 → 31. That count is both achievable (by the recursive strategy) and optimal. The legend’s sixty-four disks would need (2^{64}-1) moves.
How does the recursive solution work?
To move n disks from A to C using spare B: move (n-1) from A to B, move the largest from A to C, then move (n-1) from B to C. The recurrence (T(n)=2T(n-1)+1) with (T(1)=1) solves to (T(n)=2^n-1).
Who invented it, and when?
French mathematician Édouard Lucas introduced and sold the documented puzzle in Paris in 1883 under the anagram pseudonym N. Claus de Siam. Claims of an ancient Indian mechanical original rest on the marketing legend, not on independent archaeological evidence.
Is the Benares / end-of-the-world story true?
Treat it as product folklore. The leaflet’s sixty-four golden disks and world-ending prophecy dramatize (2^{64}-1); they do not prove a historical temple ritual that invented the toy.
What is Reve’s puzzle?
Dudeney’s early-twentieth-century four-peg (four-stool) relative. Extra pegs change optimal-move analysis; Frame–Stewart schemes apply, and four-peg optimality was proved only in 2014. Classic “Tower of Hanoi” still means three pegs and (2^n-1).
Why do programming courses use it?
The three-peg solution is a clean recursive procedure whose cost grows exponentially. Courses use it to teach recursion, induction, and the gap between a short algorithm description and (2^n-1) concrete moves—not as a generic stacking sandbox.