# 100 lightbulbs in a room [duplicate]

There are 100 lightbulbs in a room, each with it’s own switch in the off position (all lightbulbs work and start off, no funny business). There are also 100 people numbered from 1 to 100 standing outside the room.

Each person enters the room one at a time and flips the switches of certain lightbulbs.

The 1st person flips the switch of every lightbulb

The 2nd person flips the switch of every 2nd lightbulb

The 3rd person flips the switch of every 3rd lightbulb

...

All the way until the 100th person walks into the room and flips the switch of (obviously only) the 100th lightbulb.

What lightbulbs are left on after all 100 people have entered?

Note: I’m not sure where I found this puzzle, but I certainly did not come up with it myself. I just remembered it and decided to share it with you all. If nobody gets the answer within a week (I’d be less surprised to see pigs fly), I will post the answer.

• Does this answer your question? Nerds, Jocks, and Lockers Sep 24 '20 at 4:03
• Yes that answers my question. Apparently this is a duplicate. By the way the question isn’t for me it’s for the community so whoever suggested a similar question, I’m just going to not click yes or no... Sep 24 '20 at 4:07
• You can't "click yes or no" for a comment. I flagged this post as a duplicate of a previous post. That comment is autogenerated by the flag. Sep 24 '20 at 4:09
• Yeah, that’s what I meant. I’m not responding to the duplicate since I don’t know what that will even do Sep 24 '20 at 4:09

All the lights in positions of squares. In other words, lights in the positions (1, 4, 9, 16, 25, 36, 49, 64, 81, 100) will be the only ones on.

lights = [False for i in range(100)]
for i in range(1,101):
for l in range(1,101):
if l % i == 0:
if lights[l-1] == True:
lights[l-1] = False
else:
lights[l-1] = True
indices = [i + 1 for i, x in enumerate(lights) if x == True]
print(indices)