The hundred lockers, step by step

A hundred lockers in a row, all shut.

The question

In the end, how many doors are left open?

Open only where the count of divisors is odd

doors:56
divisors pairevenclosed
7×7=49
open:7
  1. Start from the only number given: 56 doors in a row, every one of them closed. Nothing is open yet.
  2. Each door numbered L is changed once for every number that divides L — once per divisor of L. Divisors come in pairs, d with L ÷ d, so the count is even and the door ends closed. That is the trap: it looks as if every door pairs off and NONE stays open — the answer 0.
  3. But one kind of number breaks the pairing: a perfect square. Its middle divisor, the √, pairs with itself and is counted once, so a square has an ODD number of divisors and stays open. So the open doors are exactly the perfect squares up to 56: 1, 4, 9, 16, …, 49.
  4. Count them: 1×1, 2×2, and so on up to 7×7 = 49, which is the largest square that fits. That is 7 of them, so 7 doors stay open.

How it works.

  1. 01

    Start from the only number given: 56 doors in a row, every one of them closed. Nothing is open yet.

  2. 02

    Each door numbered L is changed once for every number that divides L — once per divisor of L. Divisors come in pairs, d with L ÷ d, so the count is even and the door ends closed. That is the trap: it looks as if every door pairs off and NONE stays open — the answer 0.

  3. 03

    But one kind of number breaks the pairing: a perfect square. Its middle divisor, the √, pairs with itself and is counted once, so a square has an ODD number of divisors and stays open. So the open doors are exactly the perfect squares up to 56: 1, 4, 9, 16, …, 49.

  4. 04

    Count them: 1×1, 2×2, and so on up to 7×7 = 49, which is the largest square that fits. That is 7 of them, so 7 doors stay open.