Tower of Hanoi: How to Play and the Recursion Trick, Explained Simply (2026)
Try it yourself — play Tower of Hanoi now
Free in your browser, no download or sign-up.
1. The rules in one minute
Three pegs stand in a row, and a stack of disks sits on the leftmost peg, largest at the bottom, smallest on top — on this site you can play 3 to 8 disks. Two rules cover everything: you move one disk at a time (only the top disk of a stack), and you may never place a bigger disk on top of a smaller one. The goal is to rebuild the whole tower on another peg, in the same order. That is all: the puzzle has no pieces that jump, no luck, no opponents — just those two rules and your patience.
2. Solving three disks, move by move
Number the pegs A (start), B (middle), C (goal), and the disks 1 (small) to 3 (large). One optimal solution runs: 1 to C, 2 to B, 1 to B, 3 to C, 1 to A, 2 to C, 1 to C — seven moves, and seven is the minimum for three disks (23 − 1). Watch the pattern inside it: the first three moves park disks 1 and 2 on peg B, one move puts the big disk 3 on the goal peg C, and the last three moves rebuild the little tower on top of it. Everything larger than three disks repeats exactly this dance.
3. The recursive trick, explained without jargon
To move a tower of n disks from A to C, think like this: first move the top n − 1 disks out of the way onto the spare peg B (pretend they are one parcel), then move the biggest disk from A to C in a single move, then move the n − 1 disk parcel from B onto C, on top of the big disk. Each "parcel move" is the same problem one size smaller, solved the same way — that self-similarity is what programmers call recursion, and why the puzzle is the classic first lesson on it. You never have to memorise move sequences; you only ever answer one question: "where do I park the smaller tower so the big disk underneath can travel freely?"
4. Why 2^n − 1 is the minimum
Let T(n) be the fewest moves for n disks. The big disk must move once, and before it can move, all n − 1 smaller disks must sit on the spare peg, which takes at least T(n − 1) moves; after the big disk lands, the smaller tower must come on top, another T(n − 1). So T(n) = 2·T(n − 1) + 1, and with T(1) = 1 that works out to 2n − 1: 3 disks need 7 moves, 4 need 15, 5 need 31, 6 need 63, 7 need 127 and 8 need 255. The site's build counts your moves and shows the optimum next to the disk picker, so you always know how far from perfect you are.
5. Practical tips
Odd number of disks: start by moving the smallest disk to the goal peg. Even number: start it toward the middle peg. Follow that parity and never move the same disk twice in a row, and you will stay on an optimal path almost automatically. If you lose the thread, do not undo — count how many disks still need to move and re-derive: park the smaller ones, ferry the big one, rebuild. And once 8 disks feel easy, you already understand recursion better than most first-year computer science students.
FAQ
What is the minimum number of moves?
2n − 1 moves for n disks: 7 for three, 15 for four, 31 for five, 63 for six, 127 for seven, 255 for eight. Any solution claiming fewer breaks the rules.
Can I put a bigger disk on a smaller one?
No — that single prohibition is the whole difficulty. The playable build simply refuses illegal drops, the same as the physical toy.
Which peg should be the goal?
Either of the two empty pegs; the puzzle is symmetric. Habit alone makes most players pick the right-hand peg.
Why is it called Tower of Hanoi?
French mathematician Édouard Lucas published it in 1883 under the name «La Tour d'Hanoi», wrapped in a legend about monks moving 64 golden disks — at one move per second, 264 − 1 moves would take about 585 billion years.
What is the practical use of learning this?
The puzzle is the standard teaching model for recursion and algorithm analysis in computer science; the same divide-park-rebuild pattern powers sorting algorithms, backup rotation schemes and call-stack thinking.
Where can I play it free?
Right on this site's Tower of Hanoi page — 3 to 8 disks, move counter, free in the browser with no download or sign-up. Our beginner tips cover the same ideas with more worked examples.
More Tower of Hanoi guides
More games to play
More free browser games on Playnesta — pick your next round.