Skip to content

Resource · Guide or article

Tower of Hanoi

Sets out the Tower of Hanoi puzzle, its three movement rules, and the formula for the fewest moves needed. Handy as a warm-up before recursion questions.

Reviewed

Open the original: Tower of Hanoi (opens the original site in a new tab)

Add to a roadmap

Keep this resource with a roadmap you follow. It appears as your own extra resource; the roadmap's steps don't change and it doesn't count toward your tracked steps.

Source content: English

The Tower of Hanoi (also called the Tower of Brahma or Lucas' Tower and sometimes pluralized) is a mathematical game or puzzle. It consists of three rods and a number of disks of different sizes, which can slide onto any rod. The puzzle starts with the disks in a neat stack in ascending order of size on one rod, the smallest at the top, thus making a conical shape. The objective of the puzzle is to move the entire stack to another rod, obeying the following simple rules: Animation of an iterative algorithm solving 6-disk problem

PrepKit overview

PrepKit editors wrote and reviewed this overview from the source repository. It is not text from the resource itself.

Suited to
The source does not state a level
Format
Reference

What it covers

  • States the three rules for moving disks between three rods
  • Gives the minimum move count of 2^n minus 1, with 7 moves for 3 disks
  • Includes an animation of an iterative 6-disk solution

How to use it

PrepKit study advice, not a claim made by the source.

Write the recursive solution, print the moves for 3 disks, and check that there are exactly 7. Then explain the recurrence behind 2^n minus 1.

Scope and limitations

Describes the puzzle only. No recursive breakdown, code walkthrough or exercises are on the page, and the explanation sits in the Wikipedia and HackerEarth links.

Access and format

README on GitHub, trekhleb/javascript-algorithms (MIT). English, free to read.

Reviewed by PrepKit on Oct 2, 2026. Listing source commit: 85293e3e2b88

Evidence behind this overview
  • src/algorithms/uncategorized/hanoi-tower/README.md

Pages that include this

Get the PrepKit newsletter

Optional. You don't need it to use PrepKit.

How we handle your email