TITLE: Prove that $\sum^{n-1}_{i=1}i^{(n-1)} \equiv -1$ (mod $n$) for all prime $n\in\mathbb{N}$.
QUESTION [7 upvotes]: Prove that $\sum^{n-1}_{i=1}i^{(n-1)} \equiv -1$ (mod $n$) for all prime $n\in\mathbb{N}$.
I'm having a difficult time proving this problem. I was able to verify that it works for prime $n$ up to 5000 using Python.
I'm assuming induction would be useful in this case? Would love some help with this problem!

REPLY [7 votes]: It's good that you can get Python to calculate up to 5000 for you, but sometimes what might really help you is to calculate two or three cases by hand to see if you can spot any patterns.
Let's try $n = 5$:

$1^4 = 1 \equiv 1 \pmod 5$. Since $1^x = 1$ regardless of what $x$ is, we might as well go ahead and regard 1 as the taxi meter drop in this problem for all $n$.
$2^4 = 16 \equiv 1 \pmod 5$.
$3^4 = 81 \equiv 1 \pmod 5$.
$4^4 = 256 \equiv 1 \pmod 5$.

These add up to 4, which is one less than 5.
Now let's try $n = 6$. I know, that's not prime, but it might still give us an insight.

1 is the taxi meter drop.
$2^5 = 32 \equiv 2 \pmod 6$.
$3^5 = 243 \equiv 3 \pmod 6$.
$4^5 = 1024 \equiv 4 \pmod 6$.
$5^5 = 3125 \equiv 5 \pmod 6$.

These add up to 21, which is $3 \pmod 6$. In some ways, 6 is a little unusual (don't expect $i^{n - 1} \equiv i \pmod n$ whenever $n$ is composite), but we can still learn from this that if $\gcd(i, n) > 1$, then $i^{n - 1} \equiv 1 \pmod n$ is impossible.
In fact, $i^{n - 1} \equiv d \pmod n$ where $d$ is either a nontrivial divisor of $n$ or 0 (which can be considered a divisor in the context of modular arithmetic). For example, for $n = 8$, if $i$ is even, then $i^7 \equiv 0 \pmod 8$. This is because $8 = 2^3$ and $i$ being even means that $i = 2j$. Then $i^7 = 2^7 j$, which is obviously a multiple of 8.
So, if $n$ is prime, then all $i$ from 1 to $n - 1$ are coprime to $n$, which means that it's possible that $i^{n - 1} \equiv 1 \pmod n$ for each $i$. In fact, each $i$ does give $i^{n - 1} \equiv 1 \pmod n$, a fact that Pierre de Fermat noticed.
I don't know if Fermat himself proved this "little theorem," but plenty of other people have, and the proof is easy enough to follow, though I won't repeat it here. Nor will I repeat the Short One's answer, which will now be hopefully easier to understand.
There's only one thing left to address, and that's induction. Many things can be proven with induction, even when it's not the best method of proof. For this particular problem, I think the best method is simply to apply Fermat's little theorem and just let everything fall into place.