Tower of Hanoi: move the tower, one disc at a time

Move the stack to the right-hand peg without ever putting a big disc on a small one.

Loading puzzle…

Tower of Hanoi game cover

The Tower of Hanoi, online

The Tower of Hanoi is one of the most famous puzzles in mathematics: a stack of discs, three pegs, and one simple rule, never put a big disc on a small one. With three discs it is a warm-up. With eight it takes 255 perfect moves.

Play it free online with 3 to 8 discs. Your move count and time are tracked, and the page shows the minimum number of moves so you can aim for a perfect solve.

How to play Tower of Hanoi

  1. All the discs start on the left peg, largest at the bottom.
  2. Move the whole tower to the right-hand peg.
  3. You can only move the top disc of a peg, one disc at a time.
  4. A disc may never be placed on top of a smaller disc.

Tower of Hanoi tips

Know the minimum

A tower of n discs needs at least 2ⁿ − 1 moves. That's 7 moves for 3 discs, 15 for 4 and 255 for 8. Your move count shows how close you are.

Move the smallest disc every other turn

In the fastest solution, every second move uses the smallest disc, and it always travels in the same direction around the pegs.

Think recursively

To move 4 discs, first move the top 3 out of the way, move the biggest disc, then move the 3 back on top. Each smaller tower is the same puzzle again.

Frequently asked questions

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

For n discs the minimum is 2ⁿ − 1 moves. For example 3 discs need 7 moves, 5 discs need 31 and 8 discs need 255.

Why is it called the Tower of Hanoi?

The puzzle was invented by the French mathematician Édouard Lucas in 1883, who sold it with a story about a temple tower. The name stuck, though the legend is made up.

Is the Tower of Hanoi good for the brain?

It is a classic exercise in planning and working memory, and it is often used to teach recursion. Here it is simply a fun puzzle, not a medical test.

Guides for Tower of Hanoi