All games

Tower of Hanoi

Move the tower to the right-hand peg

Tap a peg to lift its top disc, then tap another peg to put it down. Keys 1, 2 and 3 work too. Your record: 0 towers moved

How to play Tower of Hanoi

The Tower of Hanoi is a famous puzzle with three pegs and a stack of discs of different sizes. The discs start on the left peg, largest at the bottom. Your job is to move the whole tower to the right-hand peg.

  1. Move one disc at a time. Tap a peg to lift its top disc, then tap the peg you want to put it on.
  2. Only the top disc can move. You can’t take a disc from the middle of a stack.
  3. Never put a bigger disc on a smaller one. A disc can go on an empty peg or on a larger disc.
  4. Rebuild the tower on the right-hand peg to win.

Start with 3 or 4 discs and work up to 8. The Fewest counter shows the smallest number of moves possible: it doubles, plus one, with every disc you add. Solve it in exactly that many for a perfect game.

Quick tips for a perfect solve

  • Think small first. To move a tower of 4, you move the top 3 out of the way, move the big disc, then move the 3 back on top.
  • Know where the smallest disc goes. With an even number of discs, move the smallest disc first to the middle peg. With an odd number, move it first to the right-hand peg.
  • Alternate moves. Every other move is the smallest disc, always going around the pegs in the same direction. In between, make the only other move that’s allowed.

Learn the simple pattern that solves any tower in the fewest moves.

Read the Tower of Hanoi guide

Tower of Hanoi FAQ

What is the fewest number of moves?

With n discs it’s 2 to the power n, minus 1. That’s 7 moves for 3 discs, 15 for 4, 31 for 5 and 255 for 8.

Where does the Tower of Hanoi come from?

It was invented by the French mathematician Édouard Lucas in 1883, sold with a story about monks moving a tower of 64 golden discs.

How long would 64 discs take?

At one move a second, the fewest moves would take about 585 billion years, far longer than the age of the universe.

Can I undo a move?

Yes. Undo takes back moves one at a time, though each undo still counts toward your total.

Is Tower of Hanoi free?

Yes. Play as often as you like in your browser on any device. No download and no account needed.