Tower of Hanoi with 5 Disks
The shortest solution is 31 moves. Play them on the board, or read every one in the list under it.
Optimal solution
31moves2⁵ − 1
- First move
- Disk 1, A → C
- At one move a second
- 31 seconds
- Difficulty
- Medium
5 disks on tower A. 31 moves to go.Step 0 of 31
| Move | Disk | From | To |
|---|---|---|---|
| 1 | 1 | A | C |
| 2 | 2 | A | B |
| 3 | 1 | C | B |
| 4 | 3 | A | C |
| 5 | 1 | B | A |
| 6 | 2 | B | C |
| 7 | 1 | A | C |
| 8 | 4 | A | B |
| 9 | 1 | C | B |
| 10 | 2 | C | A |
| 11 | 1 | B | A |
| 12 | 3 | C | B |
| 13 | 1 | A | C |
| 14 | 2 | A | B |
| 15 | 1 | C | B |
| 16 | 5 | A | C |
| 17 | 1 | B | A |
| 18 | 2 | B | C |
| 19 | 1 | A | C |
| 20 | 3 | B | A |
| 21 | 1 | C | B |
| 22 | 2 | C | A |
| 23 | 1 | B | A |
| 24 | 4 | B | C |
| 25 | 1 | A | C |
| 26 | 2 | A | B |
| 27 | 1 | C | B |
| 28 | 3 | A | C |
| 29 | 1 | B | A |
| 30 | 2 | B | C |
| 31 | 1 | A | C |
On this page
The shape of the solution
There are never 31 separate moves to remember — only three stages:
- Moves 1 to 15: build a tower of 4 disks on B.
- Move 16: disk 5 crosses to C — the only time it moves.
- Moves 17 to 31: rebuild the 4-disk tower on top of it.
Stages 1 and 3 are each the 4-disk solution, with two towers' names swapped.
Which disk moves when
Disk 1 makes half of all the moves — 16 of them, on every odd-numbered move. Each larger disk moves half as often as the one above it, which is the binary counter hiding inside the puzzle: the disk that moves is one more than the number of times you can halve the move number and still get a whole number. Move 6 halves once, to 3, so move 6 is disk 2. There is more on that in Tower of Hanoi and binary.
| Disk | Moves | First moves on | Then every |
|---|---|---|---|
| 1 | 16 | move 1 | 2 moves |
| 2 | 8 | move 2 | 4 moves |
| 3 | 4 | move 4 | 8 moves |
| 4 | 2 | move 8 | 16 moves |
| 5 | 1 | move 16 | — |
The smallest disk's circuit
With 5 disks — an odd number — disk 1 travels A → C → B → A for the whole game, never reversing. Every move in between is the only legal move that leaves disk 1 alone. Those two rules alone reproduce the list above move for move; the iterative solution explains why, and strategies turns it into something to play by.
About the 5-disk puzzle
Five disks is the size the board on this site opens with, and the size where remembering a sequence stops being a strategy. Seven moves can be learned by heart; thirty-one, for most people, cannot. What carries you through instead is the structure: moves 1 to 15 are the four-disk solution onto B, move 16 is disk 5 crossing to C, and moves 17 to 31 are the four-disk solution again, landing on C.
Five is odd, so the smallest disk goes to C first, just as with three, and it keeps circling A, C, B for all sixteen of its moves. If you can hold that one rule and the halfway point in your head, a perfect game follows without planning a single move ahead.
Thirty-one is prime, like seven, and so is five. That pairing is not a rule: 2ⁿ − 1 can only be prime when n is prime, but a prime n does not guarantee it, and eleven disks is the first counterexample — its 2,047 moves are 23 × 89. The calculator has the rest of the sequence.
Other sizes
- 4 disks15 moves — the solution that makes up each half of this one.
- 6 disks63 moves — this solution twice, with one move between.
- Solve 5 disks from a position you are stuck inThe solver finishes a half-played game in the fewest moves left, rather than starting again.
- Every solution, from 3 to 10 disksMove counts, first moves and timings side by side.
Frequently asked questions
How many moves does it take to solve Tower of Hanoi with 5 disks?
31 moves is the minimum: 2⁵ − 1 = 31. No solution with fewer moves exists, and any solution with more has wasted some.
What is the first move in 5-disk Tower of Hanoi?
Move disk 1, the smallest, from tower A to tower C. With an odd number of disks the smallest disk travels A → C → B → A for the whole game, so its first stop is C. Sending it to B first still lets you finish, but it costs one extra move.
How long does 5-disk Tower of Hanoi take to solve?
A perfect game is 31 moves, which at one move a second is 31 seconds and at three moves a second — about as fast as anyone plays by hand — 10 seconds.
Is there an easy way to remember the 31 moves for 5 disks?
Do not memorise them; remember the shape. Moves 1 to 15 build a four-disk tower on B, move 16 carries disk 5 to C, and moves 17 to 31 rebuild the four-disk tower on C. Inside those, the smallest disk moves on every odd-numbered move, always A to C to B and round again, and every even-numbered move is the only legal move that does not touch it.