100 lockers, 100 students: student N toggles every Nth locker. Which lockers end up open?
All 100 lockers start closed. Student 1 opens every locker. Student 2 then toggles every 2nd locker, student 3 every 3rd, and so on up to student 100. After all 100 students pass through, which lockers are left open?
Reveal the answer
Exactly 10 lockers: the perfect squares, 1, 4, 9, 16, 25, 36, 49, 64, 81 and 100. A locker numbered n gets toggled once for every divisor n has, and only perfect squares have an odd number of divisors (their square root pairs with itself), so they're the only ones left open.
— Robert Orenstein, Lockers — Classic locker/divisor-counting puzzle