Skip to content

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

Every move of the 5-disk solution
MoveDiskFromTo
11AC
22AB
31CB
43AC
51BA
62BC
71AC
84AB
91CB
102CA
111BA
123CB
131AC
142AB
151CB
165AC
171BA
182BC
191AC
203BA
211CB
222CA
231BA
244BC
251AC
262AB
271CB
283AC
291BA
302BC
311AC
On this page
  1. The solution
  2. The shape of the solution
  3. Which disk moves when
  4. The smallest disk's circuit
  5. About the 5-disk puzzle
  6. Other sizes
  7. Frequently asked questions

The shape of the solution

There are never 31 separate moves to remember — only three stages:

  1. Moves 1 to 15: build a tower of 4 disks on B.
  2. Move 16: disk 5 crosses to C — the only time it moves.
  3. 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.

DiskMovesFirst moves onThen every
116move 12 moves
28move 24 moves
34move 48 moves
42move 816 moves
51move 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

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.