This is a demonstration of the lightbulb problem. There are 100 lightbulbs and 100 people. Each person and lightbulb are marked with numbers 1-100. Person 1 flicks the switch of every light on. Person 2 toggles the state of the switch on every 2nd light. (If it's on, turn it off, if it's off, turn it on) Person 3 toggles the state of every 3rd light. Everybody goes trough until all 100 people have gone through the room. How many lightbulbs are lit up at the end? Here, I programmed the solution. You can press Space to watch it slowly. The solution is 10.
Notice anything about the lightbulbs that are ON at the end? They all are perfect squares. This is because perfect squares have an odd number of factors, but every other number has an even number. If there are an odd number of factors, an odd number of people toggle the switch, leaving the light on at the end. Take light 64 for example. At the end, it's on. The factors of 64 are: 1, 2, 4, 8, 16, 32, and 64. There are an odd number of factors because 64 is a perfect square. The odd number of factors means the light is on: 1 turns the light on 2 turns it off 4 turns it on 8 turns it off 16 turns it on 32 turns it off and finally, 64 turns it back on. At the end, there are 10 lightbulbs on because there are 10 perfect squares in the numbers 1-100. (1, 4, 9, 16, 25, 36, 49, 64, 81, and 100.)