November 27, 2026

Visual Math: The Tower That Needs 2ⁿ − 1 Moves

Three pegs with five coloured disks mid-game, the largest on peg C, beside the title The tower that needs 2 to the n minus 1 moves and the binary number 10000

Five disks take 31 moves, six take 63, and ten take 1,023. The free The Tower That Needs 2ⁿ − 1 Moves app on x9m8 lets the puzzle be played by hand or solved automatically, and it keeps a running move count in binary, because that count turns out to name the disk to move at every step.

Five disks, 31 moves and a binary counter, from the X9M8 channel on YouTube

Three pegs and one rule

The puzzle has three pegs and a stack of disks of different sizes, all starting on the first peg. One disk moves at a time, and no disk may sit on a smaller one. The goal is to rebuild the stack on another peg. A St Andrews history of mathematics page dates it to 1883, when it was published in Paris by a certain N. Claus de Siam, a name and college that are anagrams of Lucas d’Amiens, the mathematician Édouard Lucas.

Scientific American adds that Lucas, born in Amiens in 1842, sold the game as a solitaire puzzle under that pseudonym and claimed it was a simplified version of the Tower of Brahma.

Why the count is 2ⁿ − 1

The minimum number of moves follows from one observation. To free the largest disk, the n − 1 disks above it have to move to the spare peg. The largest disk then makes a single move, and the n − 1 disks move on top of it. An arXiv note on optimality proofs writes this as the recurrence T(n) = 2T(n − 1) + 1 with T(1) = 1, and concludes that T(n) = 2ⁿ − 1.

The small cases confirm it. Scientific American counts two disks as 3 moves and three disks as 3 + 1 + 3 = 7. Britannica carries the pattern to the toy sets sold in shops, where 8 disks require 2⁸ − 1, or 255, moves.

The app prints that minimum for whatever disk count is selected, from 1 to 10, and compares it with the moves made so far. A finished game reports either the minimum or how far over it ran.

Tower of Hanoi app after 16 moves with five disks: largest disk alone on peg C, four disks on peg B, and the move count 10000 in binary with the lowest 1 highlighted
Five disks after 16 moves: the largest disk has just crossed to peg C while the other four wait on peg B, and the binary counter reads 10000.

Reading the move count in binary

The app’s move counter is shown in binary, with the lowest 1 bit highlighted. That bit gives the disk: bit 0 is the smallest disk, bit 1 the next one, and so on. Move 1 is 1, so disk 1 moves. Move 2 is 10, so disk 2. Move 3 is 11, so disk 1 again. Move 16 is 10000, the only move in a five-disk game that touches disk 5.

The rule was checked rather than assumed. A script ran the app’s solver for every disk count from 1 to 10, confirming at each move that the move was legal, that the disk moved was the one named by the lowest 1 bit, and that the tower arrived on the last peg after exactly 2ⁿ − 1 moves. The note on optimality proofs separately points to the binary-counter discussion in the textbook it cites as CLRS.

The pattern explains why the smallest disk moves every second move, the next disk every fourth, and the largest disk exactly once, in the middle of the game.

Tower of Hanoi app showing three disks solved in the minimum 7 moves with the binary counter at 111
Three disks solved in 7 moves, the minimum, with the counter at 111 and the smallest disk on top of the finished stack.

The 64-disk legend

Lucas gave the puzzle a story. According to Scientific American, monks in a great temple had to move a tower of 64 golden disks, and before they finished the temple would crumble and the world would end. A paper from UC Davis describes the legend as one that Lucas fabricated to make the idea more appealing, so it is a sales pitch, not history.

Britannica gives the size of the task: 2⁶⁴ − 1 moves, or 18,446,744,073,709,551,615. At one move per second, and a year of 31,557,600 seconds, that comes to about 5.85×10¹¹ years. The app prints this figure in its status line, so it stays in view whatever the disk count.

Three to the n states

Each disk can sit on one of three pegs, and the order on a peg is forced by size. A paper on solving the puzzle with random moves uses this to count 3ⁿ valid states. For ten disks that is 59,049 arrangements.

The shortest solution visits 2ⁿ of them, counting the start, which is 1,024 of the 59,049 at ten disks. The path is a thin thread through a much larger graph, and the binary counter is its map.

Hearing the ruler

The companion video plays the same solution with sound. Each of the five disks has its own note, and every move sounds the note of the disk that moved, so the 31 moves become a melody. The smallest disk’s note comes back every second move and the largest disk’s note sounds once, at move 16. The video runs at 3.5 moves per second. It ends on the 64-disk figures, and it uses the same pairing of an interactive page and a short film as the rhythm-to-pitch app in this series.

Tower of Hanoi app with eight disks after 100 of 255 moves, the binary counter 01100100 and disk 3 flagged as the one that moved
Eight disks after 100 of 255 moves: the counter reads 01100100 and the lowest 1 bit marks disk 3 as the last one moved.

Sources

502 Posts

Peter Kalafatis writes and edits X9M8. He holds a bachelor's degree from LIU Post and a master's in Media Studies from The New School, with academic work in the philosophy of science, human behavior, AI, and memetics.

View All Posts

Leave a Reply

Your email address will not be published. Required fields are marked *