Lambdia

A Hundred Bulbs, 482 Flips, and Ten Survivors

Person k flips every bulb that is a multiple of k, and after a hundred passes exactly the ten perfect squares are lit. Bulb n is flipped once per divisor, and the pairing d against n/d is fixed-point free unless n is a square, so the parity is decided by algebra rather than by accumulation. The lit fraction is one over the square root of the row, and stopping the process at person 50 inverts the answer to 54 bulbs.

A hundred light bulbs stand in a row, numbered 11 to 100100, all switched off. A hundred people walk the row in turn. Person 11 flips every bulb. Person 22 flips bulbs 2,4,6,2, 4, 6, \dots. In general person kk flips every bulb whose number is a multiple of kk. After person 100100 has finished, which bulbs are on?

Ten of them: 1,4,9,16,25,36,49,64,81,1001, 4, 9, 16, 25, 36, 49, 64, 81, 100. The perfect squares, and nothing else. People asked this for the first time usually expect a scatter with no pattern, or something near half the row, and the actual answer is both sparser and far more structured than either guess. A total of 482482 flips happen, and they cancel almost perfectly.

Count the flips, not the bulbs

Person kk touches bulb nn exactly when kk divides nn. Nobody else touches it. So the number of times bulb nn is flipped is the number of positive divisors of nn, written d(n)d(n). Bulb 6464 is flipped by persons 1,2,4,8,16,32,641, 2, 4, 8, 16, 32, 64, so d(64)=7d(64) = 7.

This is also why stopping at person 100100 loses nothing. Every divisor of a number at most 100100 is itself at most 100100, so no later person would have anything left to do.

The bulb starts off and every touch changes its state, so the state at the end is decided by the parity of the flip count alone. Bulb nn is on at the end if and only if d(n)d(n) is odd. The problem has now been converted from a process into a question about a number, and the process can be forgotten.

Divisors come in pairs, with one exception

Divisors are not scattered at random through the range. If dd divides nn then so does n/dn/d, and the map dn/dd \mapsto n/d sends the divisors of nn to themselves and is its own inverse. Applying it twice gets you back where you started, which makes it an involution on a finite set. An involution splits that set into two-element orbits together with its fixed points, so

d(n)#{dn  :  d=n/d}(mod2)d(n) \equiv \#\{\, d \mid n \;:\; d = n/d \,\} \pmod 2
(1)

A fixed point is a divisor with d=n/dd = n/d, that is d2=nd^2 = n. There is at most one such positive dd, and it exists exactly when nn is a perfect square. Everything else pairs off and contributes an even amount.

Theorem

A positive integer has an odd number of divisors if and only if it is a perfect square. The pairing dn/dd \mapsto n/d is fixed-point free unless n=m2n = m^2, in which case its single fixed point is d=md = m.

Fig. 1 — The pairing d against n/d. Thirty-six leaves its square root stranded in the middle, so its divisor count is odd and its bulb stays lit. Sixty pairs up completely.

Combining the two steps: bulb nn ends up on exactly when nn is a perfect square. Between 11 and 100100 the squares are the ten numbers 121^2 through 10210^2.

{n100  :  d(n) odd}={1,4,9,16,25,36,49,64,81,100}\{\, n \le 100 \;:\; d(n) \text{ odd} \,\} = \{1, 4, 9, 16, 25, 36, 49, 64, 81, 100\}
(2)
Fig. 2 — The hundred bulbs laid out ten to a row. The survivors drift rightwards down the grid because the gaps between consecutive squares grow.

The same result through the prime factorisation

The pairing argument is the one to give under time pressure, but it is worth seeing the result fall out of the structure of dd as well, because that version generalises where the pairing does not. If n=p1e1p2e2prern = p_1^{e_1} p_2^{e_2} \cdots p_r^{e_r} then a divisor is built by choosing each exponent independently, so

d(n)=i=1r(ei+1)d(n) = \prod_{i=1}^{r} (e_i + 1)
(3)

A product of integers is odd exactly when every factor is odd, so d(n)d(n) is odd exactly when every ei+1e_i + 1 is odd, which means every eie_i is even, which means nn is a square. Take 36=223236 = 2^2 \cdot 3^2: the count is 33=93 \cdot 3 = 9, odd, so bulb 3636 is lit. Take 60=223560 = 2^2 \cdot 3 \cdot 5: the count is 322=123 \cdot 2 \cdot 2 = 12, even, so bulb 6060 is dark.

Two arguments that share no step and agree on all hundred bulbs. I trust the answer more for having both.

The half-the-row guess gets worse as the row gets longer

The reflex answer deserves a fair hearing. Roughly 482482 flips are spread over a hundred bulbs, so the average bulb is flipped nearly five times, and a coin flipped nearly five times has no strong preference. If parities behaved like independent coin tosses, half the row would be lit. They do not behave that way at all, and the reason is that the parity is pinned by an algebraic accident rather than accumulated at random.

The number of survivors in a row of NN bulbs is the number of squares up to NN, which is

#{m1:m2N}=N\#\{\, m \ge 1 : m^2 \le N \,\} = \lfloor \sqrt{N} \rfloor
(4)

At N=100N = 100 that is 1010, a tenth of the row. At N=106N = 10^6 it is a thousand, one bulb in a thousand. The lit fraction is 1/N1/\sqrt{N}and it goes to zero, so the guess "about half" is not off by a constant. It gets worse the longer the row.

The process needs all hundred people

A tempting economy is to think that the late people, who touch only one or two bulbs each, cannot matter much. They matter completely. Stop after person 5050 and the row leaves 5454 bulbs lit, more than five times the true answer, and the pattern inverts. For any nn above 5050 the second largest divisor is at most n/250n/2 \le 50, so the only divisor missing from a truncated run is nn itself. The flip count becomes d(n)1d(n) - 1, which is odd exactly when d(n)d(n) is even, so every non-square above 5050 is left glowing and the three squares 64,81,10064, 81, 100 are the ones switched off.

This is the kind of detail I would want a candidate to volunteer. The clean answer depends on the process running long enough that each bulb sees all of its divisors, and the problem is set up so that it just barely does.

Sources and further reading

The answer was checked by actually switching a hundred bulbs a hundred times, holding a list of booleans and assuming nothing about divisors, and the resulting set matched (2) exactly. On top of that, the flip count was confirmed equal to d(n)d(n) for every bulb, the pairing dn/dd \mapsto n/d was verified to be an involution with a fixed point exactly at the squares for every nn up to 300300, and the theorem above was pushed out to n=5000n = 5000, well past where a coincidence on a hundred-wide grid could survive. The count in (4) was compared against a direct count of squares for every NN up to 20002000.

Comments · 0

Be the first to comment.