Nepedia
Back to Discover
Advanced Reader
🔢

Tower of Hanoi

math Maturity 7-9 Next article →

The Tower of Hanoi is a mathematical puzzle involving three rods and a set of disks.

Tower of Hanoi
Tower of Hanoi

Each disk has a different diameter, allowing them to slide onto any rod. The puzzle begins with all disks stacked on one rod in decreasing order of size. This arrangement creates a conical shape with the smallest disk at the very top. The objective is to move the entire stack to a different rod. To succeed, a player must obey two strict rules. First, only one disk may be moved at a time. Second, no disk may be placed on top of a smaller disk. These rules ensure that the stack always maintains a specific order.

Solving the puzzle involves understanding how the number of moves grows with each added disk. The minimum number of moves required to solve the puzzle is expressed by the formula 2^n - 1, where n represents the number of disks. For example, a puzzle with three disks requires exactly seven moves to complete.

Tower of Hanoi 4
Tower of Hanoi 4

As more disks are added, the difficulty increases exponentially. This mathematical relationship is a core part of the puzzle's complexity. It demonstrates how simple rules can lead to very large numbers very quickly.

There are several ways to approach a solution, including iterative and recursive methods. An iterative solution involves a repeating pattern of moves. One method is to alternate between moving the top disk and moving another legal piece. If the number of disks is even, the top disk moves in one direction around the rods. If the number is odd, it moves in the opposite direction.

Iterative algorithm solving a 6 disks Tower of Hanoi
Iterative algorithm solving a 6 disks Tower of Hanoi

Another way to solve it is through a sequence of legal moves between specific pegs. By following a set order of moves between pegs A, B, and C, the stack will eventually reach its destination.

A recursive solution is often used to teach computer programming. Recursion is a process where a large problem is broken down into smaller sub-problems.

tower of hanoi graph
tower of hanoi graph

To move a stack of n disks from a source peg to a target peg, you must first move the top n-1 disks to a spare peg. Once the largest disk is free, you move it to the target peg. Finally, you move the n-1 disks from the spare peg onto the target peg. This strategy reduces the problem step by step until it reaches a "base case." In this puzzle, the base case is moving zero disks, which requires doing nothing.

The puzzle was invented by the French mathematician Édouard Lucas. He first presented the game in 1883 using the pseudonym "N. Claus (de Siam." This name was an anagram of his own name, Lucas d'Amiens.

UniversumUNAM34
UniversumUNAM34

He later published the game in a booklet in 1889. Various legends accompany the puzzle, suggesting ancient and mystical origins. Some stories claim the game originated in Tonkin or was practiced by priests in a Benares temple. These legends often describe a "Sacred Tower of Brahma" made of golden disks.

One famous legend involves a tower consisting of 64 golden disks. It claims that the completion of the tower will lead to the end of the world. The scale of this task is difficult to imagine. If a person made one move every second, it would take 2^64 - 1 seconds to finish. This is approximately 585 billion years.

Hanoi-Graph-7
Hanoi-Graph-7

To put this in perspective, that duration is roughly 42 times the estimated current age of the universe. These massive numbers highlight the exponential growth found in the puzzle's math.

Beyond being a game, the Tower of Hanoi is a significant tool in mathematics and science. It is a classic example used to demonstrate mathematical induction and recurrence relations. In computer science, it helps students understand how algorithms function. The puzzle also connects to other mathematical concepts, such as binary representation. The position of disks after any given move can be determined using the binary form of the move number. This deep connection between a simple game and complex logic makes the Tower of Hanoi a fundamental study in pattern and structure.

676 words

Where will your curiosity go next?

Keep exploring at your chosen reading level.

🖼️ Images & Media (8)
File:Tower of Hanoi.jpeg
Tower of Hanoi.jpeg
File:Tower of Hanoi 4.gif
Tower of Hanoi 4.gif
File:UniversumUNAM34.JPG
UniversumUNAM34.JPG
File:Iterative algorithm solving a 6 disks Tower of Hanoi.gif
Iterative algorithm solving a 6 disks...
File:tower_of_hanoi_graph.svg
tower_of_hanoi_graph.svg
File:Hanoi-Graph-7.svg
Hanoi-Graph-7.svg
File:BTOHIC.jpg
BTOHIC.jpg
File:BTOHFC.jpg
BTOHFC.jpg
More to explore

🔬 Go deeper

More advanced topics to explore

🪜 Step back

Simpler topics to build understanding

What is Nepedia?

A free, ad-free encyclopedia for children. Every article is written at five reading levels, so the same page works for a five-year-old and a fifteen-year-old — use the level switcher above to see this one change. No account needed to read.