WOLFRAM|DEMONSTRATIONS PROJECT

​

Out[]=
​
n
12
next
automatic
reset
reveal
lamps
bits
polynomial
information
In a circle of
n
lamps, initially all the lamps are on. Go clockwise around the circle, examine each lamp, and change the state of the next lamp according to the following rule. If the lamp being examined is on, then the next lamp's state is flipped (switch the lamp from on to off, or vice versa). If the lamp being examined is off, then the next lamp remains as it was. The number in the middle is the step number.
The first question is: for which values of
n
will it ever again happen that all lamps are (simultaneously) on?
The second question is: if such a value of
n
is found, can you derive a general formula (a function of
n
) for the smallest (positive) number of steps to get back to the initial state?