Quoto

Learn / Library / Brainteasers

The night porter

BrainteasersMedium

A hotel floor has doors numbered to , all locked. On night , for from to , the porter turns the key in every door whose number is a multiple of , locking an unlocked door and unlocking a locked one. After night , what is the sum of the numbers of the unlocked doors?

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

First decide which doors end unlocked, then add their numbers.

Solution
  1. Door is turned once for each divisor of , so it ends unlocked exactly when has an odd number of divisors.
  2. Divisors come in pairs and except when , so the unlocked doors are those whose numbers are perfect squares.
  3. The squares up to are to , because .
  4. Their sum is , so the answer is .

Answer: