A certain school has 1,000 lockers and 1,000 students.
The principal directs one student to open all of the lockers.
He tells the next student to close locker #2, and every second locker after that.
He tells the third student to go to locker #3 and every third one after that. The student is to close each of those lockers that is open and open each one that is closed.
He gives instructions analogous to the ones he gave #3 to each of the remaining 997 students.
Once all students have done what the principal has asked, how many lockers will be open?