There are 1 million closed school lockers in a row, labeled 1 through 1,000,000.

You first go through and flip every locker open.

Then you go through and flip every other locker (locker 2, 4, 6, etc…). When you’re done, all the even-numbered lockers are closed.

You then go through and flip every third locker (3, 6, 9, etc…). “Flipping” mean you open it if it’s closed, and close it if it’s open. For example, as you go through this time, you close locker 3 (because it was still open after the previous run through), but you open locker 6, since you had closed it in the previous run through.

Then you go through and flip every fourth locker (4, 8, 12, etc…), then every fifth locker (5, 10, 15, etc…), then every sixth locker (6, 12, 18, etc…) and so on. At the end, you’re going through and flipping every 999,998th locker (which is just locker 999,998), then every 999,999th locker (which is just locker 999,999), and finally, every 1,000,000th locker (which is just locker 1,000,000).

At the end of this, is locker 1,000,000 open or closed? Tell why.

Open – because 1,000,000 is a square (1000 * 1000 = 1,000,000).

The locker is “flipped” on each pass that is a factor in the number. If the number of lockers is a square, it will have an odd number of factors, if the number of lockers is not a perfect square, it will have an even number of factors.

Excellent answer Brent. You solved this difficult one.