LK Studio
Games / Tower of Hanoi

Tower of Hanoi

Move the whole stack to the last peg, and never put a bigger disc on a smaller one.

Tower of Hanoi Open full screen ↗

Free, no account, no download. It runs entirely in your browser — nothing is uploaded, and your scores stay on this device.

How to play

  1. Click a peg to pick up the disc on top of it.
  2. Click another peg to drop it there.
  3. A bigger disc may never rest on a smaller one.
  4. Move the entire stack to the rightmost peg to win.

The maths inside

With n discs, the minimum number of moves is exactly 2ⁿ − 1. Three discs take 7; ten take 1,023; twenty take over a million.

The reason is recursion. To move n discs you must first get the top n−1 out of the way, move the largest once, then move those n−1 back on top of it. So:

T(n) = 2·T(n−1) + 1, with T(1) = 1

which solves to T(n) = 2ⁿ − 1. Not “about” — exactly.

The classic version has 64 discs: 18,446,744,073,709,551,615 moves. One move per second, never stopping, takes about 585 billion years.

Questions

Can I beat the minimum?

No. 2ⁿ − 1 is a proven lower bound, not just a good strategy. Every valid solution takes at least that many moves, and the recursive strategy hits it exactly.

Why does it get hard so fast?

Each extra disc doubles the work. Going from 5 to 6 adds 32 moves; from 10 to 11 adds 1,024. Your patience runs out long before the maths does.

Does it save my progress?

No. Refreshing starts a new game. Nothing is stored on a server — there isn't one.

Seven more where that came from

All of them free, all of them built by one person, all of them short enough to learn in a sentence.

All games →