Temple Background

The Tower of Hanoi

Move the sacred disks from the source to the destination.
But beware: a larger disk may never rest upon a smaller one.

Moves

0

Min Moves

15

Time

00:00

Source
Auxiliary
Destination

history_edu The Legend & History

Édouard Lucas

Édouard Lucas (1883)

The puzzle was invented by the French mathematician Édouard Lucas in 1883. He marketed it under the pseudonym "N. Claus de Siam" (an anagram of Lucas d'Amiens). link

The Prophecy: According to the legend accompanying the game, there is a temple in Benares where priests are tasked with moving a tower of 64 golden disks on three diamond needles. link

The legend states that when the last move of the 64th disk is completed, the tower, the temple, and the Brahmins will crumble into dust, and the world will vanish with a thunderclap. Fortunately, solving a 64-disk tower at a rate of one move per second would take roughly 585 billion years!

functions The Mathematics

Recursion Visualization

M(n) = 2ⁿ - 1

The minimum number of moves required to solve a Tower of Hanoi puzzle with n disks is 2n - 1.

  • 3 Disks: 2³ - 1 = 7 moves
  • 8 Disks: 2⁸ - 1 = 255 moves
  • 64 Disks: 2⁶⁴ - 1 ≈ 1.84 × 10¹⁹ moves

Recursive Algorithm

FUNCTION MoveTower(n, source, dest, aux):
  IF n == 1:
    Move disk from source to dest
  ELSE:
    MoveTower(n-1, source, aux, dest)
    Move disk from source to dest
    MoveTower(n-1, aux, dest, source)

This recursive logic is a foundational concept in computer science. link