Tower of Hanoi with 7 Disks
The shortest solution is 127 moves. Play them on the board, or read every one in the list under it.
Optimal solution
127moves2⁷ − 1
- First move
- Disk 1, A → C
- At one move a second
- 2 minutes
- Difficulty
- Hard
7 disks on tower A. 127 moves to go.Step 0 of 127
| 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 |
| 32 | 6 | A | B |
| 33 | 1 | C | B |
| 34 | 2 | C | A |
| 35 | 1 | B | A |
| 36 | 3 | C | B |
| 37 | 1 | A | C |
| 38 | 2 | A | B |
| 39 | 1 | C | B |
| 40 | 4 | C | A |
| 41 | 1 | B | A |
| 42 | 2 | B | C |
| 43 | 1 | A | C |
| 44 | 3 | B | A |
| 45 | 1 | C | B |
| 46 | 2 | C | A |
| 47 | 1 | B | A |
| 48 | 5 | C | B |
| 49 | 1 | A | C |
| 50 | 2 | A | B |
| 51 | 1 | C | B |
| 52 | 3 | A | C |
| 53 | 1 | B | A |
| 54 | 2 | B | C |
| 55 | 1 | A | C |
| 56 | 4 | A | B |
| 57 | 1 | C | B |
| 58 | 2 | C | A |
| 59 | 1 | B | A |
| 60 | 3 | C | B |
| 61 | 1 | A | C |
| 62 | 2 | A | B |
| 63 | 1 | C | B |
| 64 | 7 | A | C |
| 65 | 1 | B | A |
| 66 | 2 | B | C |
| 67 | 1 | A | C |
| 68 | 3 | B | A |
| 69 | 1 | C | B |
| 70 | 2 | C | A |
| 71 | 1 | B | A |
| 72 | 4 | B | C |
| 73 | 1 | A | C |
| 74 | 2 | A | B |
| 75 | 1 | C | B |
| 76 | 3 | A | C |
| 77 | 1 | B | A |
| 78 | 2 | B | C |
| 79 | 1 | A | C |
| 80 | 5 | B | A |
| 81 | 1 | C | B |
| 82 | 2 | C | A |
| 83 | 1 | B | A |
| 84 | 3 | C | B |
| 85 | 1 | A | C |
| 86 | 2 | A | B |
| 87 | 1 | C | B |
| 88 | 4 | C | A |
| 89 | 1 | B | A |
| 90 | 2 | B | C |
| 91 | 1 | A | C |
| 92 | 3 | B | A |
| 93 | 1 | C | B |
| 94 | 2 | C | A |
| 95 | 1 | B | A |
| 96 | 6 | B | C |
| 97 | 1 | A | C |
| 98 | 2 | A | B |
| 99 | 1 | C | B |
| 100 | 3 | A | C |
| 101 | 1 | B | A |
| 102 | 2 | B | C |
| 103 | 1 | A | C |
| 104 | 4 | A | B |
| 105 | 1 | C | B |
| 106 | 2 | C | A |
| 107 | 1 | B | A |
| 108 | 3 | C | B |
| 109 | 1 | A | C |
| 110 | 2 | A | B |
| 111 | 1 | C | B |
| 112 | 5 | A | C |
| 113 | 1 | B | A |
| 114 | 2 | B | C |
| 115 | 1 | A | C |
| 116 | 3 | B | A |
| 117 | 1 | C | B |
| 118 | 2 | C | A |
| 119 | 1 | B | A |
| 120 | 4 | B | C |
| 121 | 1 | A | C |
| 122 | 2 | A | B |
| 123 | 1 | C | B |
| 124 | 3 | A | C |
| 125 | 1 | B | A |
| 126 | 2 | B | C |
| 127 | 1 | A | C |
On this page
The shape of the solution
There are never 127 separate moves to remember — only three stages:
- Moves 1 to 63: build a tower of 6 disks on B.
- Move 64: disk 7 crosses to C — the only time it moves.
- Moves 65 to 127: rebuild the 6-disk tower on top of it.
Stages 1 and 3 are each the 6-disk solution, with two towers' names swapped.
Which disk moves when
Disk 1 makes half of all the moves — 64 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 | 64 | move 1 | 2 moves |
| 2 | 32 | move 2 | 4 moves |
| 3 | 16 | move 4 | 8 moves |
| 4 | 8 | move 8 | 16 moves |
| 5 | 4 | move 16 | 32 moves |
| 6 | 2 | move 32 | 64 moves |
| 7 | 1 | move 64 | — |
The smallest disk's circuit
With 7 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 7-disk puzzle
A hundred and twenty-seven moves, and a number with more history attached than any other on this site. 127 is 2⁷ − 1, a Mersenne prime. Use 127 itself as the exponent and the result, 2¹²⁷ − 1, is prime too — a thirty-nine-digit number that Édouard Lucas proved prime in 1876, working by hand with a method he invented for the purpose. It stayed the largest known prime for seventy-five years.
Seven years after that proof, Lucas published this puzzle under a false name. So the seven-disk game is the one place where the move count of his puzzle and the most famous result of his career meet: play this solution and you are counting out the exponent of his prime. The history of the puzzle has the rest of the story.
As a game, seven disks is Hard on this board and about two minutes at a steady move a second. Seven is odd, so disk 1 goes to C first and circles A, C, B for all sixty-four of its moves.
Other sizes
- 6 disks63 moves — the solution that makes up each half of this one.
- 8 disks255 moves — this solution twice, with one move between.
- Solve 7 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 7 disks?
127 moves is the minimum: 2⁷ − 1 = 127. No solution with fewer moves exists, and any solution with more has wasted some.
What is the first move in 7-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 7-disk Tower of Hanoi take to solve?
A perfect game is 127 moves, which at one move a second is 2 minutes and at three moves a second — about as fast as anyone plays by hand — 42 seconds.
Is 127 a prime number?
Yes. 127 is 2⁷ − 1, a Mersenne prime, and it leads to a second one: 2¹²⁷ − 1 is also prime. Édouard Lucas, the mathematician who later invented the Tower of Hanoi, proved that in 1876, and it stayed the largest known prime until 1951.