Quoto

Learn / Library / Brainteasers

Half open to begin with

BrainteasersHard

lockers are numbered to . At the start every even-numbered locker is open and every odd-numbered locker is closed. Then for each from to , student toggles every locker whose number is a multiple of , opening it if closed and closing it if open. How many lockers are open at the end?

Checking an answer needs JavaScript. The hint and the solution open without it.

A whole number, a decimal, a fraction like 3/8 or a percent.

Hint

Combine the starting state with the parity of the number of divisors.

Solution
  1. Locker changes state once per divisor of , so only the perfect squares change state an odd number of times.
  2. So a non-square keeps its starting state and a square ends in the opposite state.
  3. Up to there are squares, since and ; of these, are even and are odd.
  4. Open at the end are the even non-squares, of them, and the odd squares, of them.
  5. So lockers are open.

Answer: