There is a very long hallway, illuminated by 20,000 lights. All the lights are on.
A column of 20,000 soldiers marches through the hallway, one at a time. The first soldier turns every light off.
Soldier number 2 flips every second light back on.
Soldier number 3 starts with light number 3, and flips every third light (some were off, and some were on).
This continues until soldier 20,000 has passed through the hall. Soldier 20,000 simply flips light 20,000.
The sergeant follows the soldiers through the corridor. What does the sergeant see? That is, are all the lights on or off? Is there a pattern?
I give up, show me the solution.