Skip to content
OddMaths
Back to Puzzlespuzzles

The 100 Lockers Puzzle: Which Ones Are Still Open at the End?

One hundred students, one hundred lockers, and a very strange walk down the corridor. The answer isn't what most guesses would suggest, but one clever idea explains it completely.

This puzzle has an answer that looks like a magic trick, and one clever idea explains the whole thing.

Here's the setup:

A school corridor has 100 lockers, numbered 1 to 100, and they all start closed. Then 100 students walk down the corridor, one after another.

Student 1 changes every locker: closed lockers get opened.
Student 2 changes every 2nd locker (2, 4, 6, 8, ...).
Student 3 changes every 3rd locker (3, 6, 9, 12, ...).
And so on, until Student 100 changes just locker 100.

To "change" a locker means: if it's open, close it, and if it's closed, open it.

After all 100 students have passed, which lockers are open?

Have a guess before you read on. Would you say all of them? None of them? Every other one?

Stop and Think

Stuck? Here are three hints. Use them one at a time.

Hint 1: Pick one locker, like locker 12. Which students change it?
Hint 2: A locker ends up open if it was changed an odd number of times, and closed if it was changed an even number of times. Why?
Hint 3: Look at the students who change locker 12. Do you notice any pairs?

Start Small: One Locker at a Time

Let's follow a few lockers. Student number 3 changes locker 12 because 3 goes into 12 evenly. In fact, student d changes locker n exactly when d is a divisor of n (it divides n with nothing left over).

Locker 7: students 1 and 7 change it → 2 changes → closed
Locker 6: students 1, 2, 3 and 6 → 4 changes → closed
Locker 12: students 1, 2, 3, 4, 6 and 12 → 6 changes → closed
Locker 4: students 1, 2 and 4 → 3 changes → open!
Locker 9: students 1, 3 and 9 → 3 changes → open!
Locker 1: only student 1 → 1 change → open!

Wait, what do lockers 1, 4 and 9 have in common?

The Big Idea: Divisors Come in Pairs

Take locker 12. Its divisors can be matched up into pairs that multiply to make 12:

1 × 12
2 × 6
3 × 4

Three pairs, so 3 × 2 = 6 divisors. Whenever all the divisors fit into pairs, the total is an even number, so the locker is changed an even number of times and ends up closed.

But what if one of the "pairs" is a number paired with itself? Take locker 36:

1 × 36
2 × 18
3 × 12
4 × 9
6 × 6 ← the odd one out!

The 6 is paired with itself, so it only counts once. That makes 4 pairs plus 1 extra divisor, which is 9 divisors in total. Nine is odd, so locker 36 is changed an odd number of times and ends up open.

A number is paired with itself only when it's a perfect square (6 × 6 = 36). So:

Perfect squares → odd number of changes → open
Every other number → even number of changes → closed

The Answer

The open lockers are exactly the perfect squares:

1, 4, 9, 16, 25, 36, 49, 64, 81 and 100

That's 10 lockers out of 100. We even checked it by running all 100 students on a computer, and it matched.

Try It Yourself

More lockers. If the corridor had 200 lockers, how many would be open? What about 1,000?

The busiest locker. Which locker between 1 and 100 is changed the most times?

Open or closed? In the 200-locker corridor, is locker 169 open? Is locker 150? (No sums needed!)

Check your answers: with 200 lockers, 14 are open (the squares up to 14 × 14 = 196). With 1,000 lockers, 31 are open (31 × 31 = 961). The busiest lockers are 60, 72, 84, 90 and 96, each changed 12 times (and every one ends up closed!). Locker 169 is open, because 13 × 13 = 169, and locker 150 is closed.

The OddMaths Takeaway

A puzzle with 100 students and 482 locker changes turns out to be a question about pairs. When divisors come in pairs, a locker gets changed an even number of times. The only time a pair breaks is when a number is paired with itself, and that's what makes a square number special.

So next time you see a perfect square, remember: it's the only kind of number with an odd number of divisors.

🎯 Test Your Skill

Corridor open. Lockers ready. Let's go!