This question already has an answer here:
- Nerds, Jocks, and Lockers 4 answers
In a (extremely long) corridor in a hotel there are $1000$ doors each with a single person living in the room behind. The hotel manager suddenly receives a bill and must kick out most of guests to save money. He has the $1000$ inhabitants line up in order of there room number ($1$-$1000$).
He tells the inhabitant of Room 1 to go and open every door. He then tells the inhabitant of Room 2 to go and open every second door if closed and shut it if its open. He then tells the inhabitant of Room 3 to open every third door if its closed and shut it if its open. And this goes on till the 1000th inhabitant.
He then tells the inhabitants that the people with their door open can stay.
How many can stay and which rooms have their door open?