Maths WorkshopMaths problems with full solutions
Exercise 620Number theory › Divisibility and gcdOlympiadAdded 4 Nov 2026

Counting divisors and the hundred lockers

#divisor function#perfect squares#pairing

Statement

Let d(n)d(n) be the number of positive divisors of nn.

  1. Prove that d(n)d(n) is odd if and only if nn is a perfect square.
  2. There are 100100 lockers, all closed. For k=1,…,100k=1,\dots,100, student number kk changes the state (open/closed) of every kk-th locker. Which lockers are open at the end?
  3. What is the smallest positive integer with exactly 1212 divisors?
Hint

Pair each divisor dd with n/dn/d.

Show solutionHide solution

Solution

1. The map d↦n/dd\mapsto n/d is an involution on the set of divisors of nn. Its fixed points satisfy d2=nd^2=n. So divisors come in pairs {d,n/d}\{d,n/d\} with d≠n/dd\ne n/d, except when nn is a square, where n\sqrt n is unpaired. Hence d(n)d(n) is odd iff nn is a square.

2. Locker mm is touched once by every student kk dividing mm, i.e. d(m)d(m) times. It ends open iff d(m)d(m) is odd iff mm is a perfect square. The open lockers are 1,4,9,16,25,36,49,64,81,1001,4,9,16,25,36,49,64,81,100 (ten lockers).

3. If n=∏piain=\prod p_i^{a_i} then d(n)=∏(ai+1)d(n)=\prod(a_i+1). To get 1212 divisors, the exponents are {11}\{11\}, {5,1}\{5,1\}, {3,2}\{3,2\} or {2,1,1}\{2,1,1\}. Minimal numbers: 211=20482^{11}=2048, 25⋅3=962^5\cdot3=96, 23⋅32=722^3\cdot3^2=72, 22⋅3⋅5=602^2\cdot3\cdot5=60. The smallest is 6060.

Lesson. Pair divisors d↔n/dd\leftrightarrow n/d; and recall d(n)=∏(ai+1)d(n)=\prod(a_i+1) to optimise over factorisation types.