Doors toggled by primes

100100 doors, labelled 11100100, all start open. Janitors act in turn: the kk-th janitor toggles (opens if closed, closes if open) every door whose number is a multiple of the kk-th prime (2,3,5,7,2, 3, 5, 7, \dots). After all janitors have acted, how many doors are open?

Show hints (2)+
  1. Door dd is toggled once per distinct prime factor - that's ω(d)\omega(d) times. It starts open.
  2. Open at the end iff ω(d)\omega(d) is even (including d=1d=1 with ω=0\omega=0). Count those in 1..1001..100.

Answer

Reveal answer →

57

Want the full step-by-step worked solution? It's part of Premium - along with a worked solution for every question in the bank.

Asked at: Jane Street, Two Sigma

Related questions