Move all n disks from peg A to peg C — one disk at a time, never a bigger disk on a smaller one. Watch the recursion unroll into the classical 2ⁿ − 1 moves, or grab a disk yourself and race the optimal solver. Trace panel shows the recursive call structure exactly as hanoi(n, A→C via B) expands.
Play manually: click a peg to grab its top disk, click another peg to drop it. Illegal drops (larger on smaller) are refused and don't count as moves. The counter only advances on legal placements.
The classical recursion is hanoi(n, src, tgt, aux) = hanoi(n−1, src, aux, tgt); move(src→tgt); hanoi(n−1, aux, tgt, src). Every leaf is one physical disk move. Highlighted line = the move just executed.
Let T(n) be the number of moves to shuttle n disks from source to target. The recursion is T(n) = 2·T(n−1) + 1, with T(1) = 1. Unrolling: T(n) = 2ⁿ − 1. No strategy does better — the largest disk must move at least once, and to free it, the top n−1 disks must first be parked on the auxiliary peg (T(n−1) moves), then re-stacked on the target (another T(n−1) moves).
For n = 64 (the mythical Brahma temple version) the priests need 2⁶⁴ − 1 = 18 446 744 073 709 551 615 moves. At one move per second that's ~585 billion years — many times the age of the universe.
Frame-Stewart for four pegs conjectures roughly O(2^(√(2n))) — dramatically fewer moves — but this playground sticks to the classical three-peg rules.