The 100 Lockers Puzzle: Why Only 10 Stay Open After 100 Passes
Imagine 100 closed lockers in a row and 100 people taking turns walking past them. Each person changes the state of certain lockers: closed becomes open, and open becomes closed. After all 100 passes, just 10 lockers are open—numbers 1, 4, 9, 16, 25, 36, 49, 64, 81, and 100. Why those ten? They are the perfect squares.
The surprise is that nobody needs to keep track of every opening and closing to find the answer. A small experiment reveals a pattern, and a simple idea about factors proves it.
The Rules: One Pass at a Time
All 100 lockers start closed and are numbered from 1 to 100.
- Person 1 changes every locker.
- Person 2 changes every second locker: 2, 4, 6, and so on.
- Person 3 changes every third locker: 3, 6, 9, and so on.
- The pattern continues until person 100 changes locker 100.
To change a locker means to toggle it. If it is closed, the person opens it; if it is open, the person closes it.
After the first pass, all 100 lockers are open. After the second, every even-numbered locker is closed again. By the time person 10 arrives, the row looks much harder to follow. That is the puzzle’s clever trap: it invites you to watch the entire row when you only need to study one locker at a time.
Try a Smaller Row First
Suppose there are only 10 lockers and 10 people following the same rules. Which lockers will finish open?
Locker 6 is changed by people 1, 2, 3, and 6. It opens, closes, opens, and closes: four changes leave it closed.
Locker 9 is changed by people 1, 3, and 9. It opens, closes, and opens: three changes leave it open.
Try the others, and you will find that lockers 1, 4, and 9 remain open. Those numbers have something in common: they are 1 × 1, 2 × 2, and 3 × 3.
This smaller version gives us a promising guess for the 100-locker puzzle. But why do squares behave differently? To be certain, we need to know exactly who visits each locker.
The Key: A Locker Changes When Its Number Is Divisible
Person 4 changes locker 20 because 20 appears when you count by fours: 4, 8, 12, 16, 20. Person 6 does not change locker 20 because counting by six never lands on 20.
In other words, person 4 changes locker 20 because 4 divides 20 evenly. The people who change a locker are exactly the numbers that divide its locker number evenly. These numbers are called its divisors, or factors.
Take locker 12. Its divisors are 1, 2, 3, 4, 6, and 12, so it gets changed six times. Starting closed, it finishes closed.
Locker 16 has a different story. Its divisors are 1, 2, 4, 8, and 16. Five changes leave it open. The University of Cambridge’s Plus magazine uses this same factor-counting idea to explain a version of the puzzle with locked doors.
The rule is now simple: an odd number of changes leaves a locker open; an even number leaves it closed. The final question is why some numbers have an odd number of divisors.
Why Divisors Usually Come in Pairs
Think about locker 12 again. Its divisors can be matched up according to which two numbers multiply to make 12:
- 1 × 12
- 2 × 6
- 3 × 4
Each pair contains two different numbers. Six divisors means six changes, so locker 12 finishes closed.
Now look at locker 16:
- 1 × 16
- 2 × 8
- 4 × 4
The last pair is unusual. The two numbers are the same. Person 4 changes locker 16 once, not twice. That gives locker 16 five distinct divisors instead of six.
The same thing happens with every perfect square—a number made by multiplying a whole number by itself. For locker 36, the factor pairs are 1 × 36, 2 × 18, 3 × 12, 4 × 9, and 6 × 6. The final pair meets in the middle, leaving 36 with nine distinct divisors. Nine changes leave it open.
A number that is not a perfect square never has that matching middle pair. All its divisors pair with different divisors, so their total is even. That is why only perfect-square lockers stay open. If you would like a visual introduction to these numbers, Math Is Fun’s guide to squares and square roots lists the early perfect squares.
Counting the 10 Open Lockers
Once you know that only square-numbered lockers survive, there is no need to replay 100 passes. Just list the squares that do not exceed 100:
1² = 1, 2² = 4, 3² = 9, 4² = 16, 5² = 25, 6² = 36, 7² = 49, 8² = 64, 9² = 81, and 10² = 100.
The next square is 11² = 121, which is beyond the end of the row. So there are exactly 10 open lockers. A perfect square is the square of a whole number; the locker numbers in this puzzle begin at 1, so zero is not part of the list.
Notice that locker 100 belongs in the answer. Its divisors include 1 and 100, 2 and 50, 4 and 25, 5 and 20, plus 10 in the middle because 10 × 10 = 100. That is nine changes altogether. Person 100 makes the last change, reopening it.
What If There Were More Lockers?
The reasoning works for any version with N lockers and N passes, numbered from 1 to N. The open lockers are the perfect squares no greater than N.
With 25 lockers, they are 1, 4, 9, 16, and 25: five open lockers. With 50, they are 1, 4, 9, 16, 25, 36, and 49: seven open lockers. With 121, locker 121 joins the list, bringing the count to 11.
Here is a quick way to count them: find the largest whole number whose square is no greater than the number of lockers. For 100 lockers, that number is 10. For 50 lockers, it is 7, because 7² = 49 fits but 8² = 64 does not.
The starting condition matters, too. Our answer assumes every locker begins closed. If all 100 lockers instead began open, an odd number of changes would leave a locker closed. In that version, the 10 square-numbered lockers would finish closed and the other 90 would finish open.
The Amazing Feat Is Finding the Right Question
One hundred people making repeated changes sounds like a bookkeeping nightmare. Yet the whole puzzle turns on two questions: Who changes a particular locker? And does that locker get changed an odd or even number of times?
That shift—from tracking a busy row to counting one locker’s factors—is what makes the solution so satisfying. For another example of a simple-looking challenge with a hidden number pattern, explore Puzzles Arcade’s chessboard and wheat puzzle. Or see how a different kind of mathematical rule shapes the 15-puzzle’s impossible challenge.
The next time a puzzle seems to demand hundreds of little calculations, pause before doing them. There may be a smaller, more revealing question hiding underneath.


