There are nn lamps L0,,Ln1L_0, \ldots, L_{n-1} in a circle (n>1n > 1), where we denote Ln+k=LkL_{n+k} = L_k. (A lamp at all times is either on or off.) Perform steps s0,s1,s_0, s_1, \ldots as follows: at step sis_i, if Li1L_{i-1} is lit, switch LiL_i from on to off or vice versa, otherwise do nothing. Initially all lamps are on. Show that:

(a) There is a positive integer M(n)M(n) such that after M(n)M(n) steps all the lamps are on again;

(b) If n=2kn = 2^k, we can take M(n)=n21M(n) = n^2 - 1;

(c) If n=2k+1n = 2^k + 1, we can take M(n)=n2n+1M(n) = n^2 - n + 1.