Over at your local high school, the main hallway has a bank of 100 lockers. All of these lockers, labeled 1 through 100, start with their doors closed.
The resident class clown decides to open every locker door. He then returns to the front of the row and toggles (opens/closes) every 2nd locker door (2,4,6,8...) in the hallway. That is, he goes to every 2nd locker, if it's open, he closes it, if it's closed, he opens it.
The class clown repeats this for every 3rd locker (3,6,9...), then every 4th locker (4,8,12...), then every 5th (5,10,15...), etc. until he finally repeats for every 100th locker.
After the class clown is done, which locker numbers will end up closed, which will end up open?
The number of times a door will be toggled is based on the number of divisors the locker number has. For example, door #6 will be toggled on pass 1, 2, 3 and 6. Further note that most numbers have an even number of divisors. This makes sense since each divisor must have a matching one to make a pair to yield the product. For example, 1*6=6, 2*3=6.
The only numbers that do not have an even number of divisors are the square numbers, since one of their divisors is paired with itself. For example, door #9 is toggled an odd number of times on passes 1, 3 and 9 since 1*9=9 and 3*3=9.
Thus, all non-square numbered lockers will end up closed and all square numbered lockers will end up open.