There are 100 bulbs in a room. 100 strangers have been accumulated in the adjacent room. The first one goes and lights up every bulb. The second one goes and switches off all the even numbered bulbs - second, fourth, sixth... and so on. The third one goes and reverses the current position of every third bulb (third, sixth, ninth… and so on.) i.e. if the bulb is lit, he switches it off and if the bulb is off, he switches it on. All the 100 strangers progresses in the similar fashion.
After the last person has done what he wanted, which bulbs will be lit and which ones will be switched off ?
Ponder over the bulb number 56, people will visit it for every divisor it has. So 56 has 1 & 56, 2 & 28, 4 & 14, 7 & 8. So on pass 1, the 1st person will light the bulb; pass 2, 2nd one will switch it off; pass 4, light it; pass 7, switch it off; pass 8, light it; pass 14, switch it off; pass 28, light it; pass 56, switch it off.
For each pair of divisors the bulb will just end up back in its preliminary state. But there are cases in which the pair of divisor has similar number for example bulb number 16. 16 has the divisors 1 & 16, 2 & 8, 4&4. But 4 is recurring because 16 is a perfect square, so you will only visit bulb number 16, on pass 1, 2, 4, 8 and 16… leaving it lit at the end. So only perfect square bulbs will be lit at the end.