LearnWave
Learn it. Master it.

A Square and A Cube

The hundred lockers

Solve the queen's puzzle of the 100 lockers, and find out why only some of them stay open.

Queen Ratnamanjuri left her ratnas (precious stones) behind a puzzle. Her son Khoisnam and 99 relatives were told: if all 100 of you answer together, you share the ratnas equally; but whoever solves it first keeps everything.

The minister showed them a room of 100 lockers, all closed. Each person got a number from 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, Person 4 every 4th, and so on, until all 100 have had a turn.

The lockers left open give the code.

Khoisnam knew the answer before anyone moved. Here's how he thought.

A locker starts closed. Toggle it an odd number of times and it ends open; an even number of times and it ends closed. So the only question is: how many people touch each locker?

Person k touches locker n only when k is a factor of n. So the number of toggles is the number of factors of the locker's number. Locker 6: Person 1 opens it, Person 2 closes it, Person 3 opens it, Person 6 closes it. Those four (1, 2, 3, 6) are exactly the factors of 6. Four is even, so locker 6 ends closed.

Factors usually come in pairs. Each factor has a partner factor, and the two multiply to give the number: for 6, 1 pairs with 6 and 2 pairs with 3. Pairs always give an even count.

But sometimes a pair is the same number twice: 4 = 2 × 2, 9 = 3 × 3, 36 = 6 × 6. That factor is its own partner, so it is counted once, and the total becomes odd.

'A number that can be expressed as the product of a number with itself is called a square number, or simply a square.' And 'the only numbers that have an odd number of factors are the squares'. So the open lockers are 1, 4, 9, 16, 25, 36, 49, 64, 81 and 100.

Inside those ten lockers was one more clue: the passcode is the first five locker numbers touched exactly twice. A locker touched twice has exactly two factors, 1 and itself, so its number is prime. The code is 2-3-5-7-11.

Factors come in pairs, so the count is even, unless the pair is a number with itself.
Only square numbers have an odd number of factors.

Practise this lesson

Questions that get harder as you improve, a Tutor that helps without giving the answer away, and progress you can see. Free for every learner.

No account, no email address. Opens the real product.