**Solution**

For example,

After the first pass every door is open.

Second pass you only visit the even doors (2,4,6,8…) so now the even doors are closed and the odd ones are opened.

Third time through you will close door 3 (opened from the first pass), open door 6 (closed from the second pass), etc..

**Hint : Door 12 will be visited in 1, 2, 3, 4, 6 & 12 pass (divisors..)**

You can figure out that for any given door,

Say door #42, you will visit it for every divisor it has.

**42 has 1 & 42, 2 & 21, 3 & 14, 6 & 7. **

Pass 1 open the door,

Pass 2 close it.

Pass 3 open,

Pass 6 close.

Pass 7 open …. pass 14 close, pass 21 open, pass 42 close. **for every pair of divisors the door will just end up back in its initial state**.

So you might think that every door will end up closed?

Well what about door #9. 9 has the divisors 1 & 9, 3 & 3. but 3 is repeated because 9 is a perfect square, so you will only visit door #9, on pass 1, 3, and 9… leaving it open at the end.

**Only perfect square doors will be open at the end.**

**
**This Puzzle was asked in Housing.co.in