At Thousand Locker High, there are exactly 1000 students and 1000 lockers. It's the first day of school,
and all 1000 lockers are initially open. The first student walks down the hall (beginning at the
first locker) and reverses the position (open/close) of each locker. Now all the lockers are closed.
Next, the

*second* student walks down the hall and reverses the position of every

*second*
locker. Now all the even numbered lockers are open. Next, the

*third* student walks down the hall
and reverses the position of every

*third* locker. Next, the

*fourth* student walks down the
hall and reverses the position of every

*fourth* locker and so forth until all 1000 students have
walked down the hall with the 1000th student reversing only the position of the 1000th locker. How many
lockers are now closed?

**ANSWER**:

*31 lockers.*
**EXPLANATION**: The number of times a locker is opened or closed is equal to the number of
factors the locker number has. For example, locker number 21 has four factors (1, 3, 7, and 21) and will
be opened and closed a total of four times. The first student will close it, the 3rd student will open it,
the 7th student will close it, and finally, the 21st student will open it.

All lockers that are reversed an even number of times will end in the open position (the same position
they started in). All lockers that are reversed an odd number of times will end in the closed position.
So the question is how many numbers between 1 and 1000 have an

*odd* number of factors?

If you take certain numbered lockers at random, you will notice that most have an even number of factors
because the factors are "paired up". For example, the locker number 12 has six factors which can be paired
up as: 1 x 12, 2 x 6, and 3 x 4. It turns out that the only numbers that have an

*odd* number of
factors are

**square numbers (perfect squares)** such as 1, 4, 9, 16... Take locker number 16
for instance. The 1 pairs up with the 16, the 2 pairs up with the 8, but the 4 is unpaired (since it
essentially pairs with itself). So locker number 16, like all square numbers (pefect squares), has an odd
number of factors.

The highest square number (perfect square) that is 1000 or less is 961 (31 squared) which is of course
the 31st square number (perfect square). So 31 lockers will end up closed. With a calculator, you can
make a list of all the square numbers (perfect squares) between 1 and 1000. There are 31 in all: 1, 4, 9,
16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225, 256, 289, 324, 361, 400, 441, 484, 529, 576, 625,
676, 729, 784, 841, 900, and 961. Each of those 31 lockers will end up closed.