Thank you for visiting this site. This article covers the grand old master of the puzzle world: “the Tower of Hanoi.”
Three pegs and disks of different sizes. A simple game of moving a stack of disks to another peg — yet the puzzle comes garnished with a legend: “when all 64 golden disks have been moved, the world will end.” Do the arithmetic and moving 64 disks takes, at minimum, about 18.4 quintillion moves — at one move per second, about 580 billion years, more than 40 times the age of the universe. Let’s see how astronomical numbers gush out of just three pegs, and meet the powerful idea hiding inside: recursion.
What Is the Tower of Hanoi?
The Tower of Hanoi is a puzzle that lets you feel exponentially exploding procedures arising from two simple rules. The rules:
- Three pegs; on the left peg sit n disks of different sizes, stacked largest at bottom
- Move one disk at a time, and only the top disk of any peg
- A larger disk may never rest on a smaller one
- Finish by moving the whole stack to another peg in the same order
Two disks solve in 3 moves; three in 7. Child’s play. But each added disk swells the required count at slightly more than doubling pace: 10 disks take 1,023 moves; 20 exceed a million; 64 exhaust the lifetime of the universe. We’ll unmask the source of that growth shortly.
Born in 1883 from Mathematician Lucas’s Sense of Mischief
The Tower of Hanoi’s provenance is precisely known: it was released as a toy in 1883 by the French mathematician Édouard Lucas. Lucas was a serious mathematician remembered for his work on primes, but the toy was marketed as the invention of a fictitious “Professor N. Claus of Siam.” N. Claus is an anagram of Lucas — an impish contrivance, oriental mystique and all.
The 64-disk legend traces here too. The tale — “monks in an Indian temple are transferring 64 golden disks, and when they finish, the world will crumble” — was popularized in 1884 by the science writer Henri de Parville, the year after release, and is considered not genuine folklore but promotional fiction. Like the Einstein legend attached to the zebra puzzle, puzzles attract retrofitted origin stories — but Hanoi’s fabrication was first-class work. After all, it comes backed by the calculation that completion takes 580 billion years: as a doomsday device, ideal.
Why the Minimum Is Exactly 2^n − 1
The puzzle’s core fits in one sentence: “moving n disks decomposes into moving n−1 disks twice, plus moving the largest disk once.”
To move the bottom, largest disk to the target peg, the n−1 disks on top of it must first be evacuated wholesale to the spare peg — there is no other way. Move the largest, then bring the n−1 evacuees back on top of it. Every solution is necessarily the three-act structure: “relocate n−1 → the big single move → relocate n−1 again.”
Therefore the minimum for n disks is “twice the minimum for n−1 disks, plus one.” One disk takes 1 move, so the sequence runs 3, 7, 15, 31… — in general, 2^n − 1 moves. Each added disk nearly doubles the workload, so 64 disks reach 2^64 − 1: about 18.4 quintillion moves, a monstrous figure.
Lay out the 7 moves of the 3-disk case and the structure shows plainly:
- Smallest to target peg. 2. Middle to spare peg. 3. Smallest onto middle (evacuation of the top two complete).
- Largest to target peg (the whole enterprise’s pivot — one single move).
- Smallest to start peg. 6. Middle to target. 7. Smallest onto middle (evacuees restored — done).
The first three and last three moves are exactly “the 2-disk procedure,” with the big move sandwiched between. The decomposition is the move list.
And that no fewer moves can ever suffice follows from the same decomposition: at the instant the largest disk moves, everything else must already be evacuated onto a single other peg — and both the evacuation and the return each cost the full n−1-disk minimum. The solution method and the proof of its optimality both fall out of one decomposition — the puzzle’s mathematical elegance.
A Primer on Recursion
“Reduce a problem to a smaller copy of itself” — this idea is called recursion, one of the backbones of computer science, and the Tower of Hanoi has appeared as its finest teaching specimen in programming primers the world over.
Recursion’s gift is that you never plan the whole procedure move by move. The 7-disk tower runs 127 moves, but all you must remember is the decomposition: “the 6-disk version twice, plus the big move.” The 6-disk version delegates to the 5-disk one, the 5 to the 4… until the buck stops at the trivial floor: “one disk, one move.” Quicksort, directory-tree traversals, fractal rendering — much of practical algorithmics is built on this pattern of splitting a big problem into smaller self-similar pieces.
Binary Rhythms, and a Reach into Psychological Testing
Viewed from the mathematics side, unexpected pictures hide within. List the moves from the start and the smallest disk moves every other turn, the second-smallest once every 4 moves, the third every 8 — exactly the rhythm of a binary counter’s carries. And plot every legal configuration as a dot, connecting pairs one move apart, and there emerges the Sierpiński triangle — the fractal of nested triangles. The full map of a recursively built puzzle turns out to be a recursively built shape. Too good to be true, except it is true.
Hanoi shows up in other fields as well. Psychology uses it as a test of planning ability (executive function), and its refinement, the Tower of London test, is a fixture of neuropsychology. In backup rotation, there really is a scheme called “Tower of Hanoi rotation” that borrows the disks’ movement pattern: the regularity of disk one moving every other step and disk two every fourth step transfers into balancing fresh and old backups across few tapes. A 19th-century toy pulling shifts in the modern server room — a delightful thought.
Never Getting Lost, and the Four-Peg World
Is There a Trick to Following the Shortest Path Without Thinking?
Only two rules to remember: (1) move the smallest disk every other turn; (2) always cycle the smallest disk in the same direction (toward the target peg if n is odd, the reverse if even). On the turns when the smallest doesn’t move, only one legal move exists anyway — no decisions required. Follow these two rules and you trace the optimum automatically. That a recursively designed procedure collapses into so simple an iteration rule is one of the puzzle’s hidden pleasures.
What Happens with Four Pegs?
The counts plummet. Eight disks need 255 moves on three pegs but only 33 on four. One extra parking peg dramatically softens the exponential blast. The four-peg optimum — the Frame–Stewart method proposed in 1941 — was long “believed optimal,” but rigorous proof arrived only in 2014. Complete resolution of a children’s toy cost modern mathematics 130 years.
How Do You Get the Legend’s “580 Billion Years”?
2^64 − 1 = 18,446,744,073,709,551,615 — about 18.4 quintillion moves. At one move per second that is roughly 584.9 billion years, over 40 times the universe’s age (about 13.8 billion years). This 2^64 − 1, incidentally, equals the total grains in the famous fable of doubling rice on the 64 squares of a chessboard. As illustrations of how terrifying 64 doublings are, Hanoi’s tower and the chessboard’s rice stand as the twin peaks.
Related Logic Puzzles
See time optimized by a setup move in “the bridge and torch problem”; shortest procedures via maps of states in “the river crossing problem”; and the limit thought experiment of infinitely many operations, “Thomson’s lamp.”
Summary
This article covered “the Tower of Hanoi.”
From a minimal world of three pegs and two rules rises a span of time exceeding the universe’s lifetime. Its source was a single line of structure: “the n-disk problem decomposes into two copies of the (n−1)-disk problem.” See that decomposition, and the shortest procedure, its move count, and the proof that nothing shorter exists all land in your hands at once.
When a job feels too large to grip, remember the tower. Is there “a smaller job of the same shape” hiding inside it? The instant you find one, a 127-move labyrinth folds up into one line of decomposition. The wisdom Lucas smuggled into a toy is still on active duty in programming, 140 years on.
To return to the full list of logic and probability puzzles, follow the link below.
Thank you for reading. We hope to see you in the next article.
📚 Series: Logic & Probability Puzzles (9/11)


