🧩 Puzzle & board games · free, no sign-up
Tower of Hanoi: one disk at a time.
Play Tower of Hanoi
Loading Tower of Hanoi…
How to play Tower of Hanoi
- Tap a peg to lift its top disk, then tap the peg you want to drop it on. On a keyboard, press 1, 2, 3 (and 4, 5).
- A disk can only go on an empty peg or on a bigger disk.
- Build the whole tower on the peg marked GOAL. The game shows the best possible number of moves.
- Stuck? A hint shows a perfect next move (it costs a star). 🤖 Show me plays the perfect solution.
- Tier 2 starts from scrambled positions; tier 3 allows only next-door moves, or adds a fourth and fifth peg.
Tips and strategy
- With an odd number of disks, move the smallest disk to the goal peg first; with an even number, to the other peg.
- The smallest disk moves every other turn, always going round the pegs in the same direction.
- To move n disks, first move the top n − 1 out of the way, move the biggest, then move the n − 1 back on top. That idea is called recursion.
- The best number of moves for n disks is 2ⁿ − 1: 7 for 3 disks, 15 for 4, 31 for 5, 63 for 6, 127 for 7.
Keep playing
More games you might like
FAQ
Tower of Hanoi: questions
What is the minimum number of moves for the Tower of Hanoi?
For n disks and three pegs, the fewest moves is 2ⁿ − 1: 7 moves for 3 disks, 15 for 4, 31 for 5, 63 for 6, 127 for 7 and 255 for 8.
How do you solve the Tower of Hanoi with three disks?
It takes at least seven moves. Move the smallest disk to the goal, move the middle disk to the spare peg, put the small disk on the middle disk, move the largest disk to the goal, then move the two smaller disks onto the largest disk.
What is the trick to solving the Tower of Hanoi?
Move the smallest disk every other turn, always round the pegs in the same direction, and in between make the only other legal move. Or think recursively: move the top n − 1 disks aside, move the largest disk, then move the n − 1 disks back on top.
What does the Tower of Hanoi teach in computer science?
It is a visual way to understand recursion, base cases and algorithms. A program can solve n disks by solving the n − 1 disk puzzle twice, with one move of the largest disk between them.
How does the four-peg version change things?
An extra peg gives more room, so far fewer moves are needed: 8 disks take 255 moves on three pegs but only 33 on four.
Is the Tower of Hanoi good for kids?
Yes. With 3 disks it suits children from about 7; larger towers build planning, patience and pattern spotting, and older students can explore the maths of recursion.
Is it free?
Yes. No sign-up or ads, and your stars are saved in your browser.
Start a conversation
Questions about classes?
A parent or guardian can share the learner's age, level and goals, and we'll suggest a starting point and confirm the format before anything is booked.
- Tell us the learner’s age or grade and goals
- We’ll suggest a suitable class or learning path
- We’ll confirm format, timing and fees with a parent or guardian