MindYourPuzzleMindYourPuzzle
Insight · ★★★☆☆ · ~6 min

The 100 Lockers

100 students toggle 100 lockers. Which stay open? The answer is pure number theory.

by MindYourPuzzle

A deceptively simple setup with a beautiful number-theory punchline.

A school hallway has 100 lockers, all closed, and 100 students.

  • Student 1 walks by and toggles every locker (opens all of them).
  • Student 2 toggles every 2nd locker (2, 4, 6, …) — closing them.
  • Student 3 toggles every 3rd locker (3, 6, 9, …) — opening or closing each.
  • …and so on: Student k toggles every k-th locker, up through Student 100.

"Toggle" means: if it's open, close it; if closed, open it.

After all 100 students have passed, how many lockers are left OPEN?

(Answer with the number.)

Hints