Home > Mathematica, Mathematics > Open Lockers

## Open Lockers

Hundred Lockers is an exercise about number properties and parity.

The animation above shows the state of the lockers after each passage of Willy Wonka’s assistant.

Image [100] provides the solution.

The answer is the square numbers: 1,4,9,16,25,36,49,64,81,100.

At the end of the procedure the status of the locker (closed 0, open 1) is  the number of factors of locker number N mod 2, e.g.

• locker 10: 10 has 4 factors (1,2,5,10), 4 mod 2 =0, hence the locker is closed
• locker 25: 25 has 3 factors  (1,5,25) 3 mod 2 =1, hence the locker is open

Square numbers have an odd number of factors:

Every number can be expressed as the product of power of primes:

$N =\prod_{j}^n p_j^{j_k}$

Let $\phi (N)$ be the number of factors of $N$:

$\phi (N) =\prod_j^n (j_k +1)$

For square numbers all $j_k$ are even, hence $\phi (N) \text{ mod } 2 \equiv 1$