Queen Ratnamanjuri leaves a puzzle in her will. In a secret room there are 100 lockers and 100 people, numbered 1 to 100.
- Person 1 opens every locker.
- Person 2 toggles every 2nd locker (closes it if open, opens it if closed).
- Person 3 toggles every 3rd locker, person 4 every 4th, and so on up to person 100.
Which lockers stay open at the end? Her son Khoisnam knows before anyone starts.
The key idea: locker number k is touched once by every person whose number is a factor of k. Locker 6 is touched by persons 1, 2, 3 and 6: open, closed, open, closed. Four factors, an even count, so it ends closed. A locker ends open only if it has an odd number of factors.
Partner factors: factors come in pairs whose product is the number. For 6 the pairs are 1 × 6 and 2 × 3. Pairs normally give an even count. The count becomes odd only when a factor pairs with itself, as in 4 = 2 × 2 or 9 = 3 × 3 or 36 = 6 × 6.
A number that is a number multiplied by itself is a square number (a square). Only squares have an odd number of factors, so the open lockers are 1, 4, 9, 16, 25, 36, 49, 64, 81, 100.
Second clue: the passcode is the first five lockers touched exactly twice. A number with exactly two factors (1 and itself) is a prime, so the code is 2-3-5-7-11.
Tap the diagram to enlarge it
- Factors come in partner pairs
- Squares have one self-partner
- Primes have exactly two factors