General

The 100 Lockers Riddle: How Many Stay Open?

In the 100-locker problem: 100 students pass 100 lockers numbered 1–100; student n toggles every locker whose number is divisible by n. How many lockers are open at the end?

Get the app for 2,500+ riddles — free

People also ask

What is the answer to the 100 lockers riddle?

10 lockers stay open. A locker ends up open only if its number was toggled an odd number of times, which happens exactly for perfect squares: 1, 4, 9, 16, 25, 36, 49, 64, 81 and 100 — ten lockers in total.

Why do only the perfect-square lockers stay open?

A locker is toggled once for each divisor of its number. Divisors come in pairs, so most numbers have an even count and the locker ends closed. Perfect squares have one unpaired divisor (the square root), giving an odd count, so they finish open.

How do you solve the 100 lockers problem?

Count how many times each locker is flipped — once per divisor. Since only perfect squares have an odd number of divisors, just count the perfect squares from 1 to 100. There are 10, so 10 lockers remain open.