Solution February 13, 2007
Solution I from int-e
Let
be a primitive root (http://en.wikipedia.org/wiki/Primitive_root_modulo_n) modulo
. Then,
covers every non-zero remainder modulo
exactly once for
, so
Therefore,
by Fermat's little theorem (http://en.wikipedia.org/wiki/Fermat's_little_theorem).
If
does not divide
, then
, so we can divide by
and obtain
.
If
, we can evaluate
directly using Fermat's little theorem again:
This covers all cases.
Solution II from landen
For
a positive integer and
a prime, what are the possible values of:
From Fermat's little theorem (http://en.wikipedia.org/wiki/Fermat's_little_theorem) it is sufficient to reduce
to give only a finite number of values for each prime.
Exploring with some famous sums:
The
factors suggest that for
We can prove this by induction on
and stopping at
so the base case is easy.
Consider:
Summing both sides of this equation from
to 
The left side of the equation had all middle terms cancel. If we now assume
by induction hypothesis then
:


The final conclusion is valid because
.