Skip to content
Omnikalc

Tower of Hanoi calculator: how many moves and how long for any number of discs

Enter the number of discs and the time per move to get the minimum number of moves of the Tower of Hanoi, the time to solve it and the number of moves of any disc.

Updated on
Your inputs

Value out of range

s

Value out of range

Value out of range

Results

Minimum number of moves

4,095

Time to solve the puzzle
1:08:15
Moves of the smallest disc
2,048
Moves of the disc you follow
128
Most discs you could solve in 80 years of non-stop play
31

The Tower of Hanoi is a classic puzzle where n discs move between three pegs. The Tower of Hanoi calculator gives the minimum number of moves 2ⁿ − 1, the time to solve it, the moves of the smallest disc, the moves of any disc and the largest puzzle that can be solved in a lifetime.

How the calculation works

  • Enter the number of discs on the first peg. The classic puzzle with 3 pegs is solved by moving one disc at a time, never putting a larger disc on a smaller one.
  • Enter the time for one move in seconds, to get the total time to solve the puzzle.
  • Enter the number of a disc to follow, with 1 for the smallest. The smallest disc moves every other move, and the largest moves only once.
  • The calculator gives the minimum number of moves 2ⁿ − 1, the time, the number of moves of the smallest disc 2ⁿ⁻¹, the moves of the disc you follow 2ⁿ⁻ᵏ and the largest puzzle you could solve in 80 years.

Example

With 12 discs, the minimum number of moves is 2¹² − 1 = 4,095. At one move per second, the puzzle takes 1 hour 8 minutes 15 seconds. The smallest disc moves 2¹¹ = 2,048 times. The fifth disc moves 2⁷ = 128 times. With non-stop play for 80 years at one move per second, you could solve a puzzle of up to 31 discs, which needs 2,147,483,647 moves.

Why it matters

The calculator helps students, teachers and puzzle fans to see how fast an exponential grows, to plan a classroom demonstration with a number of discs that can be solved in time, and to illustrate recursion in computer science. It shows why each disc added doubles the work.

Good to know

The formula gives the minimum number of moves for the three-peg puzzle with the standard rules. With four or more pegs, the minimum number of moves is much smaller and is given by the Frame-Stewart conjecture. For a demonstration, plan the time for mistakes, since the real time is longer than the minimum. The number of discs is limited to 50.

The logarithm calculator reverses a power of two, the exponential growth calculator models repeated doubling, the arithmetic-geometric series calculator sums related sequences, and the Fibonacci calculator explores another famous recurrence.

Frequently asked questions

What is the Tower of Hanoi?

The Tower of Hanoi is a puzzle with three pegs and a stack of discs of different sizes on the first peg, the largest at the bottom. The goal is to move the whole stack to another peg, one disc at a time, without ever placing a larger disc on a smaller one. The French mathematician Édouard Lucas invented it in 1883.

How many moves does it take?

The minimum number of moves for n discs is 2ⁿ − 1. To move n discs, you move n − 1 discs to the spare peg, move the largest disc, and then move the n − 1 discs on top of it. This gives the recurrence M(n) = 2 × M(n − 1) + 1, which solves to 2ⁿ − 1. Each extra disc doubles the work.

What is the legend of the 64 discs?

A legend tells that monks move a tower of 64 golden discs in a temple, and that the world will end when they finish. The puzzle needs 2⁶⁴ − 1, about 1.8 × 10¹⁹ moves. At one move per second, it would take about 585 billion years, which is more than 40 times the age of the universe.

How often does each disc move?

The smallest disc moves every second move, 2ⁿ⁻¹ times in total. The disc number k, counted from the smallest, moves 2ⁿ⁻ᵏ times, and the largest moves once. The sum of all these moves is 2ⁿ − 1. The smallest disc always moves in the same direction around the three pegs.

Was this calculator helpful?

Thanks for your feedback!

Results are estimates provided for information purposes. They do not replace professional advice.