Home › Puzzle › Tower of Hanoi
🗼

Tower of Hanoi

Puzzle

Play Tower of Hanoi online for free

Move the whole stack of disks to the right peg, one disk at a time, never placing a big disk on a small one.

The Tower of Hanoi is a famous mathematical puzzle invented by the French mathematician Édouard Lucas in 1883. A stack of disks sits on the left peg, largest at the bottom. You must move the entire stack to the right-hand peg, moving only one disk at a time and never putting a larger disk on top of a smaller one.

You can choose between three and seven disks. The minimum number of moves for n disks is 2 to the power of n, minus one - so 7 moves for three disks and 127 moves for seven. Can you solve it perfectly?

How to play

  1. Choose how many disks to play with.
  2. Tap a peg to pick up its top disk.
  3. Tap another peg to drop the disk there.
  4. A larger disk can never go on top of a smaller one.
  5. Move the whole tower to the right-hand peg to win.

Tips and strategy

  • With an odd number of disks, move the smallest disk to the right peg first; with an even number, move it to the middle peg first.
  • The smallest disk moves on every other turn, always in the same direction around the pegs.
  • Think of it recursively: to move n disks, first move n-1 disks out of the way.

Frequently asked questions

What is the minimum number of moves?

It is 2ⁿ − 1, where n is the number of disks.

Who invented the puzzle?

The mathematician Édouard Lucas published it in 1883.

Why is it used in programming classes?

It is a classic example of a problem solved neatly with recursion.

Game details

  • Category: Puzzle
  • Platforms: Any modern browser on Android, iPhone, iPad, Windows, Mac and Linux
  • Controls: Touch, mouse and keyboard
  • Price: Free, no in-game purchases
  • Developer: BrightAdsSolution

🎮 You may also like

All games →