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

5 disks, from peg 1 to peg 3
Fewest moves possible31
The smallest disk first goes topeg 3
The largest disk moves on move16
With four pegs instead of three13 moves
Time at one move per second31 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.

Number of moves of each disk
DiskMoves
Disk 1 (smallest)16
Disk 28
Disk 34
Disk 42
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).

  1. Disk 1: peg 1 → 3
  2. Disk 2: peg 1 → 2
  3. Disk 1: peg 3 → 2
  4. Disk 3: peg 1 → 3
  5. Disk 1: peg 2 → 1
  6. Disk 2: peg 2 → 3
  7. Disk 1: peg 1 → 3
  8. Disk 4: peg 1 → 2
  9. Disk 1: peg 3 → 2
  10. Disk 2: peg 3 → 1
  11. Disk 1: peg 2 → 1
  12. Disk 3: peg 3 → 2
  13. Disk 1: peg 1 → 3
  14. Disk 2: peg 1 → 2
  15. Disk 1: peg 3 → 2
  16. Disk 5: peg 1 → 3
  17. Disk 1: peg 2 → 1
  18. Disk 2: peg 2 → 3
  19. Disk 1: peg 1 → 3
  20. Disk 3: peg 2 → 1
  21. Disk 1: peg 3 → 2
  22. Disk 2: peg 3 → 1
  23. Disk 1: peg 2 → 1
  24. Disk 4: peg 2 → 3
  25. Disk 1: peg 1 → 3
  26. Disk 2: peg 1 → 2
  27. Disk 1: peg 3 → 2
  28. Disk 3: peg 1 → 3
  29. Disk 1: peg 2 → 1
  30. Disk 2: peg 2 → 3
  31. 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.