There are $100$ lights lined up in a long room. Each light has its own switch and is currently off. The room has an entry door and an exit door. There are $100$ people lined up outside the entry door. Each light is numbered consecutively from $1$ to $100$. So is each person.
Person No. $1$ enters the room, switches on every light, and exits. Person No. $2$ enters and flips the switch on every second light (i.e. turn off lights $2$, $4$, $6$...). Person No. $3$ enters and flips the switch on every third light (i.e. toggle lights $3$, $6$, $9$...). This continues until all $100$ people have passed through the room. How many of the lights are on at the end?
$\textbf{Answer}$
The answer is $10$. All the lights whose labels are square numbers are on. The rest are off.
$\textbf{Analysis}$
It is easy to see that
It may become clear that a light will remain on if and only if it is switched an odd number of times. This makes sense, doesn't it? Therefore, the problem becomes how to determine which lights will be switched an odd number of times. This is equivalent to determining which integers have an odd number of divisors. Only square numbers meet this requirement.