- Moves
- 0
- Minimum
- 31
- Fewest from here
- 31
- Time
- 0:00
Tower of Hanoi with 5 Disks
Five disks take 31 moves: long enough that you need a method, short enough to finish in a minute or two once you have one.
Quick facts
| Fewest moves possible | 31 |
| The smallest disk first goes to | peg 3 |
| The largest disk moves on move | 16 |
| With four pegs instead of three | 13 moves |
| Time at one move per second | 31 seconds |
Five is odd, so the smallest disk goes to peg 3 first. Keep an eye on move 16: that is the one move of the largest disk, and the top four disks are waiting on peg 2.
How often each disk moves
The smallest disk does half of all the work. Each disk moves half as often as the one below it, and the largest disk moves exactly once.
| Disk | Moves |
|---|---|
| Disk 1 (smallest) | 16 |
| Disk 2 | 8 |
| Disk 3 | 4 |
| Disk 4 | 2 |
| Disk 5 (largest) | 1 |
A pattern worth remembering
Count how many times 2 divides the move number, and add one: that is the disk to move. Move 1 is odd, so it moves disk 1. Move 2 is divisible by 2 once, so it moves disk 2. Move 4 is divisible by 2 twice, so it moves disk 3. Move 16 is divisible by 2 exactly 4 times, so it is the one move of disk 5. You can check every line of the list below against it.
The complete solution
All 31 moves, in order. Peg numbers are 1 (left), 2 (middle) and 3 (right).
- Disk 1: peg 1 → 3
- Disk 2: peg 1 → 2
- Disk 1: peg 3 → 2
- Disk 3: peg 1 → 3
- Disk 1: peg 2 → 1
- Disk 2: peg 2 → 3
- Disk 1: peg 1 → 3
- Disk 4: peg 1 → 2
- Disk 1: peg 3 → 2
- Disk 2: peg 3 → 1
- Disk 1: peg 2 → 1
- Disk 3: peg 3 → 2
- Disk 1: peg 1 → 3
- Disk 2: peg 1 → 2
- Disk 1: peg 3 → 2
- Disk 5: peg 1 → 3
- Disk 1: peg 2 → 1
- Disk 2: peg 2 → 3
- Disk 1: peg 1 → 3
- Disk 3: peg 2 → 1
- Disk 1: peg 3 → 2
- Disk 2: peg 3 → 1
- Disk 1: peg 2 → 1
- Disk 4: peg 2 → 3
- Disk 1: peg 1 → 3
- Disk 2: peg 1 → 2
- Disk 1: peg 3 → 2
- Disk 3: peg 1 → 3
- Disk 1: peg 2 → 1
- Disk 2: peg 2 → 3
- Disk 1: peg 1 → 3
Other sizes
3 disks4 disks6 disks For the rule behind these lists see how to solve the Tower of Hanoi; for why 5 disks need 31 moves see the formula; to finish a position that has gone wrong, use the solver.