Solution: Day 1, problem 1


Call the numbers in question "good." Clearly every good number is square-free, since if p2np^{2} | n for some prime pp then the congruence an+1=a(modn)a^{n+1} = a (mod n) fails for a=pa = p.
Write
n=p1...prn = p_{1} ... p_{r} with p1<p2<...<prp_{1} < p_{2} < ... < p_{r}, with pip_{i} prime.
It then follows from Fermat's little theorem (correctly stated!) that nn is good if and only if pi1p_{i} - 1 divides nn for every ii, and since pi1p_{i} - 1 is smaller than and hence coprime to the primes pjp_{j} with jij ≥ i

This means that pi1p_{i} - 1 divides p1...pi1p_{1} ... p_{i-1} for each integeri=1,...,ri = 1, ... , r. Taking i=1i = 1 forces (p11)1(p_{1} - 1) | 1, so if r1r ≥ 1 then p1=2p_{1} = 2 (this is obvious anyway by taking a=1a = -1 in the defining property of "good"). Similarly, taking i=2i = 2 then gives (p21)2(p_{2} - 1) | 2, so if r2r ≥ 2 then p2=3p_{2} = 3.

Continuing, we find: if r3r ≥ 3, then (p31)p1p2=6(p_{3} - 1) | p_{1} p_{2} = 6, so p3=7p_{3} = 7; if r4r ≥ 4 then (p41)p1p2p3=42(p_{4} - 1) | p_{1} p_{2} p_{3} = 42, so p4=43p_{4} = 43 (the numbers d+1d + 1 are not prime for the other divisors of 42 larger than 6): and if r5r ≥ 5 then p51p_{5} - 1 must divide p1p2p3p4=1806p_{1} p_{2} p_{3} p_{4} = 1806. But 1, 2, 6 and 42 are the only divisors of 1806 with d+1d + 1 prime, sop5p_{5} cannot exist.

Hence r4r ≤ 4 and the only good integers are 1, 2, 6, 42, and 1806.