Learn / Library / Brainteasers
The night porter
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.
Hint
First decide which doors end unlocked, then add their numbers.
Solution
- Door is turned once for each divisor of , so it ends unlocked exactly when has an odd number of divisors.
- Divisors come in pairs and except when , so the unlocked doors are those whose numbers are perfect squares.
- The squares up to are to , because .
- Their sum is , so the answer is .
Answer: