
Imagine a corridor with one hundred lockers and a line of students moving down it. The first student touches every door. The second touches every other door. The third touches every third door, and so on, until student one hundred reaches only the last locker. Each touch flips a locker’s state: open becomes closed, closed becomes open. At the end, ten doors remain open, and their numbers make a pattern that feels almost too neat: 1, 4, 9, 16, 25, 36, 49, 64, 81, 100.

The row and its quiet rule
The puzzle asks us to keep track of many small actions without losing the rule that governs them. A locker is touched by the students whose numbers divide evenly into its number. Locker 5, for instance, is visited by student 1 and student 5, because those are its factors. It opens on the first pass, then closes on the fifth.
That example is easy to hold in mind. The whole row is harder. By the time the hundredth student has passed, trying to remember every door’s history is a poor use of attention. The puzzle is asking for a change of scale: stop following each student’s route and look at the number of times a particular locker is touched. A solution account from 36 University points toward that factor-counting approach, while the Braingle version states the same central pattern.
The final state depends on whether a locker is toggled an even or odd number of times. Two touches cancel: one opens it, the next closes it. Three leave it open; four leave it closed. The corridor’s long sequence of footsteps reduces to a single question for each door: how many factors does its number have, and is that count odd or even?
Where the factor pairs break
For most numbers, factors arrive in pairs. Locker 10 has the pairs 1 and 10, 2 and 5. Each pair contributes two visits, so the total is even. We can follow the actual switches: student 1 opens locker 10, student 2 closes it, student 5 opens it, and student 10 closes it. Four touches, closed at the end.
This pairing suggests an elegant but incorrect first guess: if factors come two at a time, every locker gets an even number of touches and every door ends shut. The reasoning works right up to the point where the number has a factor that pairs with itself. For 25, the factors are 1, 5, and 25. The outer factors pair, 1 with 25, but 5 is left in the middle because 5 multiplied by itself is 25.
That lone factor changes the count from even to odd. Student 1 opens locker 25, student 5 closes it, and student 25 opens it again. The door stays open. The apparent exception is not an interruption of the rule. It is the place where the rule becomes visible: a perfect square has a square root that meets itself in the factor list.
Counting the passes without walking them
Locker 40 makes the contrast plain. Its factors are 1, 2, 4, 5, 8, 10, 20, and 40. Those are eight visits, so the locker finishes closed. The list can be arranged in pairs: 1 with 40, 2 with 20, 4 with 10, and 5 with 8. No factor is left over.
For any number that is not a perfect square, each factor has a distinct partner. If a factor is called d, its partner is the number divided by d. The two multiply to make the locker number. A non-square cannot have a factor equal to its own partner, so every factor belongs to a two-member pair. Its total number of factors must be even.
A square is different because its square root is its own partner. For 36, for example, 6 multiplied by 6 gives 36. The other factors pair off, but 6 occupies the shared middle point. That leaves an odd total. Since an odd number of toggles leaves a locker open, the open doors are exactly the perfect squares. The source accounts state this odd-factor rule; the pairing argument supplies the missing proof.

Two routes into the pattern
There are two useful ways to approach the puzzle. One is to shrink it. Try twenty lockers, write down which remain open, and see whether their numbers suggest a pattern. Small cases make the toggling visible without asking the reader to manage one hundred doors at once. The danger is stopping at the pattern and treating a few examples as proof.
The other route is to choose a locker and trace its factors. This gives a direct audit. Locker 10 has four visits. Locker 25 has three. Locker 40 has eight. The counts explain those particular endings, then the factor-pair argument explains every locker in the row. Experiment gives the eye something to notice; proof shows why the pattern cannot fail.
Return to the corridor after the last student has passed. Most doors are shut, not because the movement has become mysterious, but because their visits have canceled in pairs. Ten numbers keep a remainder: each is a square, each has one factor that meets itself, and each records that unpaired touch in its final open position.



