PuzzlePage

Tower of Hanoi

Daily deal + unlimited

How do you solve the Tower of Hanoi?

To move a tower of n discs, first move the top n − 1 discs to the spare peg, then move the largest disc to the target peg, then move the n − 1 discs on top of it. Applied over and over, this takes exactly 2ⁿ − 1 moves, the fewest possible: 7 moves for 3 discs, 15 for 4, 31 for 5 and 255 for 8. A shortcut: move the smallest disc every other turn, always in the same direction.

Tower of Hanoi rules

  • Three pegs; all discs start on the left peg, largest at the bottom.
  • Move one disc at a time, always the top disc of a peg.
  • Never place a larger disc on a smaller one.
  • Win by moving the whole tower to the right-hand peg.

Tips and strategy

  • With an odd number of discs, move the smallest disc first to the target peg; with an even number, to the spare peg.
  • Alternate: smallest disc, then the only other legal move, then the smallest disc again.
  • Use Auto-solve to watch the recursive pattern, then try to match it.

A short history of Tower of Hanoi

The puzzle was invented by the French mathematician Édouard Lucas in 1883, sold with a legend about monks moving 64 golden discs. At one move per second, 64 discs would take about 585 billion years.

Tower of Hanoi questions

What is the minimum number of moves for the Tower of Hanoi?

2ⁿ − 1, where n is the number of discs: 3 discs take 7 moves, 4 take 15, 5 take 31, 6 take 63, 7 take 127 and 8 take 255.

Why is the Tower of Hanoi used to teach recursion?

Because the solution is defined in terms of itself: to move n discs you move n − 1 discs, move one disc, then move n − 1 discs again. It is a classic first example in maths and computer science classes.

Can I use this Tower of Hanoi in class?

Yes. Project it, pick the disc count, and let students predict the minimum moves before using Auto-solve to check. It is free and needs no accounts.

Is Tower of Hanoi free to play?

Yes. Tower of Hanoi on PuzzlePage is free in any browser on a phone, tablet or computer, with no download and no sign-up. Your streaks and best times are kept on your device. The page shows a few ads, which never cover the game, and the Player Club removes them.

Can I put Tower of Hanoi on my own website?

Yes. Sign up free with your email at puzzlepage.app/embed, click the link we send, and copy the embed code. The game runs inside your page, restyled to your colors, with a small PuzzlePage credit.

Put Tower of Hanoi on your website

Teachers, bloggers and activity coordinators can add Tower of Hanoi to their own page for free. Sign up with your email on the embed page, click the link we send you, and copy the code. It matches your site's colors and keeps a small PuzzlePage credit.

More classic games

Browse all classic games →

Tower of Hanoi on PuzzlePage is an original implementation of a traditional game, with its own design. It is not affiliated with any operating system or software publisher.