This is a modification to the usual 100 lightbulbs in a room puzzle.
Like before, the first person flips the switch of every lightbulb.
However, while the second person also starts from the first bulb and flips the switch of every second lightbulb, they do not stop at the 100th lightbulb. Rather, after the $100^\text{th}$ bulb, they continue on to the $[100+2\pmod{100}]^\text{th}$ (i.e. second) and keeps flipping every second bulb still until the total number of bulbs they have flipped is 100.
Similarly, the third person flips the switch of every third lightbulb, but does not stop at the $99^\text{th}$ bulb, they continue to the $[99+3\pmod{100}]^\text{th}$ (i.e. second again) bulb and continues until the total number of bulbs they have flipped is 100.
The general rule is that the $n^\text{th}$ ($1\leq n\leq 100$) person flips the $[kn\pmod{100}]^\text{th}$ for $1\leq k\leq 100$.
This carries on until all 100 people have flipped 100 bulbs each. The task is to find the bulbs which are switched on at the end.
I've written a script that determines which ones are:
arr = [0 for _ in range(100)]
for i in range(1,101):
for j in range(1,101):
bulb = i*j
bulb = bulb%100
arr[bulb-1] += 1
arr[bulb-1] = arr[bulb-1]%2
print(arr)
and get that no bulbs are left switched on at the end. However, I find it hard to think of a way to answer this problem logically, and also generalise to say $N$ bulbs. How should I approach this question?
bulb = bulb%100
can return0
, and thenarr[-1]
is accessed. $\endgroup$arr[-1]
refers to the last element. And ifbulb%100=0
we indeed want to access the 100th bulb. $\endgroup$