a puzzle to explore

The 100 switches puzzle

simulator by Aarthy Balasubramanian

There are 100 lights, numbered 1 to 100, all starting in the OFF position. There are also 100 people, numbered 1 to 100, who walk past one after another. Person i toggles every switch that's a multiple of i — toggle just means flipping it, ON to OFF or OFF to ON.

Which lights will be ON after all 100 people have passed, and why?

Click "next" below to bring in people one at a time. Try it up to person 20 first, and see if a pattern shows up before you go any further.

the rule
  • Person 1 toggles every switch.
  • Person 2 toggles every 2nd switch.
  • Person i toggles every ith switch.
  • Person 100 toggles only switch 100.
person
0
on
0
off
100
tap any switch to see what's behind it
guiding questions
  1. Before you press play — how many people do you think will toggle switch 1? How many will toggle switch 100?
  2. Run it all the way through. Which switch numbers are on at the end?
  3. What do the numbers on your list have in common?
  4. Click on a few switches and look at their prime factorizations. What's different about the exponents for a switch that's on compared to one that's off?
  5. If there were 400 switches instead of 100, how many would you expect to be on at the end? Explain your reasoning.