Brainteasers

The 100 Lockers Puzzle

NeetQuant · August 2026 · 3 min read

The problem

100 closed lockers. Person 1 toggles every locker. Person 2 toggles every 2nd. Person 3 every 3rd, and so on to person 100. Which lockers are open at the end?

The answer

The perfect squares: 1, 4, 9, 16, 25, 36, 49, 64, 81, 100. Ten lockers.

Why

Locker n is toggled once by each person whose number divides n. So locker n ends open exactly when n has an odd number of divisors.

Divisors come in pairs: if d divides n, so does n/d. For 12: (1,12), (2,6), (3,4) - six divisors, even, so locker 12 ends closed.

The pairing fails in exactly one case: when d equals n/d, which means n = d^2. A perfect square has one divisor that pairs with itself, making the total odd.

16 has divisors 1, 2, 4, 8, 16 - five of them, because 4 is its own partner.

Saying it well

The clean one-liner: "Divisors pair up, so the count is even unless the number is a perfect square, where the square root pairs with itself."

That sentence is the whole solution and it demonstrates you understand the structure rather than having spotted a pattern in the first few cases.

Follow-ups

How many for 1000 lockers? floor(sqrt(1000)) = 31.

Which locker is toggled most? The one with the most divisors under 100 - that is 96, with 12 divisors (and 60 and 72 also have 12).

What if people 1 to 50 only? Then divisors above 50 never fire, breaking the pairing argument. Locker n ends open when it has an odd number of divisors at most 50 - a genuinely different and more interesting problem.

That last variant is a good test of whether you understood the mechanism or memorised the answer.

More in brainteasers and combinatorics.

Keep practising

Practise quant interview questions free

Create a free account to attempt hundreds of questions with hints and answer checking, and to run the timed simulators.

Start practising free

Frequently asked questions

Which lockers stay open in the 100 lockers puzzle?
The perfect squares - 1, 4, 9, 16, 25, 36, 49, 64, 81 and 100. A locker ends open when it has an odd number of divisors, and only perfect squares do, because the square root pairs with itself.