Question 26952
It definitely helps to break this problem into smaller pieces and draw a picture.


Lets say we only have 10 people and 10 lockers. If person 1 opens all of the lockers, they're all open. Now person 2 goes, and all of the even numbered lockers are shut. Now it's 3's turn: locker 3 is shut, locker 6 is open again, and 9 is shut. Four takes a shot and locker 4 and 8 are reopened. 5 goes and 5 and 10 are shut. Students 6, 7, 8, and 10 only shut locker 6, 7,8, and 10 respectively; while person 9 opens locker #9.


So if we look at say locker #6, person 1 opens it, person 2 closes it, person 3 opens it, and finally person 6 closes it. So there are 4 people who interact with it (notice how its an even number). While with locker 4, only students 1,2,4 touch it, and it stays open. So by this reasoning, if an even number of people touch it, it stays closed. If an odd number of people touch it, it stays open. To find out how many people touch it, we simply find the number of factors the number has. With 6 there are 4 factors: 1,2,3,6. The four factors simply cancel each other out (one action of opening is undone by another action of closing). While the number 4 has 3 factors: 1,2,4. These factors dont cancel so it stays open. It turns out that every number, except the perfect squares, has an even number of factors. Think about it, to multiply to say 40, one could go 1*40,2*20,4*10,5*8,8*5,10*4,20*2,40*1. All of these factors are paired up, which means there are an even number of factors. Even prime numbers have an even number of factors, they are divisible by their own number and 1 (ie 61=1*61). However, even though perfect squares may seem to have an even number of factors (for instance 9:1*9,3*3,9*1) there is a repeated factor of 3. So there are only 3 factors in this number. This is true for all perfect squares, since there's always a repeated factor of the square root value. So every perfect square locker number will remain open because they have an odd number of factors. This makes it easier to count the number of open lockers since we only have to find perfect squares. So here's the list of perfect squares (and open lockers):


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
961
And there happens to be 31 perfect squares less than 1000.


So there are 31 lockers left open. I hope this makes sense.