31 lockers. All the perfect squares (1,4,9,…,961).
A locker \(l\) is visited by nth student, if \(n\) is a factor of \(l\). If an even number of students visit the locker, then it will end up closed (every pair of students will open, and then close it). Perfect squares are the only numbers with an odd number of factors.