The name locker puzzle is used for two different puzzles involving numbered lockers. In the toggling version,
lockers are initially closed. On pass
, for
, 2, ...,
, every locker whose number is a multiple
of
is toggled, changing an open locker to
closed or a closed locker to open. The problem asks which lockers remain open after
all
passes (University of California, Riverside).
Locker
is toggled once for each positive divisor of
. Its final state is therefore open iff
its number of positive divisors is an odd
number. Pairing each divisor
with
shows that the pair members are distinct except when
. Thus exactly the square
numbers remain open. There are
open lockers, where
is the floor function.
For 100 lockers, the open numbers are 1, 4, 9, 16, 25, 36, 49, 64, 81, and 100.
The locker puzzle of Curtin and Warshauer (2006) is instead the 100 prisoners problem, in which each prisoner searches a limited number of lockers for an assigned number. Its permutation strategy is distinct from the divisor pairing in the toggling puzzle.