The Legend and History of the Tower of Hanoi

Tower of Hanoi guide · 4 min read

The Tower of Hanoi is wrapped in one of the best origin stories in all of puzzling: a temple, 64 golden disks, and the end of the world. The history is a little more down to earth than the legend, but no less interesting. The puzzle was invented in 1883 by a French mathematician with a flair for marketing, and the dramatic tale of the Tower of Brahma was part of the sales pitch. Here's who invented the Tower of Hanoi, where the legend came from, and why, mathematically, you don't need to worry about the world ending. To play the puzzle behind the story, see how to solve the Tower of Hanoi.

Who invented the Tower of Hanoi?

The Tower of Hanoi was invented by Édouard Lucas, a French mathematician, in 1883. Lucas is well known in mathematics for his work on number theory and the Fibonacci-related sequence that bears his name, the Lucas numbers. He marketed the puzzle as a toy, and it was an immediate hit in France.

There's a playful detail in how he released it. The puzzle was sold under the name of "N. Claus de Siam, mandarin of the college of Li-Sou-Stian," a pseudonym that is an anagram. Unscramble it and you get "Lucas d'Amiens" (Lucas was from Amiens) and a nod to "Saint Louis," his school. The exotic, far-eastern framing, Hanoi, Siam, a mandarin, was pure period flavor designed to make the toy intriguing. That's also why the puzzle is sometimes called the Lucas Tower.

The legend of the Tower of Brahma

To sell the puzzle, Lucas attached a legend, and it has stuck ever since. The story goes like this:

In a temple in the Indian city of Benares (Varanasi), beneath a dome that marks the center of the world, there are three worn posts and 64 golden disks. Since the beginning of time, priests have been moving these disks one at a time, following the same rules as the puzzle: only one disk moves at a time, and a larger disk may never sit on a smaller one. When the priests complete the transfer of all 64 disks, the legend says, the temple will crumble and the world will end.

This is the Tower of Brahma, and it's the reason the puzzle feels so much grander than a simple stacking toy. Whether any such temple existed is doubtful; the legend was almost certainly Lucas's own invention or embellishment. But it captured imaginations, and it teaches a genuine mathematical lesson hidden inside the drama.

Why the world is safe

Here's the beautiful part: the legend is also a math problem with a precise answer. The minimum number of moves to transfer n disks is 2ⁿ − 1, a formula we explain fully in the Tower of Hanoi formula. For the priests' 64 disks, that's:

2⁶⁴ − 1 = 18,446,744,073,709,551,615 moves

About 18.4 quintillion moves. Even if the priests worked perfectly and moved one disk every second without ever resting, finishing would take roughly 585 billion years. The universe is only about 13.8 billion years old, so the priests have barely begun. The "end of the world" is, mathematically, an extraordinarily long way off.

That twist, a doomsday legend that turns out to be a lesson in exponential growth, is exactly why the Tower of Hanoi remains a favorite in math classrooms. It makes the abstract idea of how fast 2ⁿ grows feel vivid and a little eerie.

From a French toy to a computing classic

Lucas died in 1891, but his puzzle found a second life he never could have predicted. When computer science emerged in the twentieth century, the Tower of Hanoi became the standard teaching example for recursion, because its solution calls itself in such a clean, visual way. Generations of programming students have written their first recursive function to solve it, as our Tower of Hanoi in Python guide shows.

The puzzle also inspired real-world applications. The "Tower of Hanoi" backup rotation scheme, used to schedule data backups efficiently, borrows the puzzle's structure. And psychologists use Tower of Hanoi style tasks to study planning and problem-solving, a topic we cover in what the Tower of Hanoi teaches.

A puzzle that outlived its legend

More than 140 years after Lucas sold his clever toy with a made-up doomsday myth, people are still moving the disks, now on screens instead of wooden pegs. The legend turned out to be marketing, but the mathematics it pointed to is real and timeless. That blend of story and structure is why the Tower of Hanoi endures.

Want to take your place among the disk-movers? You won't take 585 billion years. Start with the 3-disk version and see how quickly the pattern clicks.