There is quite a bit of documentation on this problem online. Try googling "first student touches all lockers" without the quotes. I would give you some specific websites, but I'm unable to post links. Good luck!
Lets look at locker number "n". All the lockers are locked to begin with. Since all the lockers are opened on the 1st pass, locker "n" is now open. For locker "n" to be closed on the 2nd pass, n must be divisible by 2. For the locker to be opened on the 3rd pass, it must be divisible by 3. For the locker to be closed on the 4th pass, it must be divisible by 4. Clearly, the locker is either opened or closed as long as the locker number is divisible by each successive divisor of "n". After the one thousandth student has made his contribution to the celebration, locker "n" will only be open if it was acted upon an odd number of times. We can therefore conclude that locker "n" will be open if, and only if, the number "n" has an odd number of factors or divisors. But the only numbers that have an odd number of factors/divisors are the perfect squares. Thus, if "n" is open, it is one of the perfect squares. The lockers that remain open are therefore numbers 1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225, 256, 289, 324, 361, 400, on up to 961.
For each locker number, find all of the exact divisors including 1 and the number itself. If the number of divisors is odd, then the number of people who reversed the locker is odd, and the locker is open. If the number of divisors is even, then the number of people who reversed the locker is even, and it is closed. The only numbers with an odd number of divisors are the perfect squares. Therefore, the lockers that remain open are those identified by the perfect squares.