I've this problem that I did halve of the proof but I can't do the rest of it.
Let $p$ be an odd prime. We define $S_n$ as $S_n = 1^n +2^n + ... +(p-1)^n$
Prove that $S_n \equiv \begin{cases} 0 & \text{if $p-1 \nmid n $ } \\ -1, & \text{if $p-1 \mid n$ } \end{cases}$
Partial proof:
If $p-1\mid n$, then $\varphi(n)=p-1=kn$ for some k. As $p$ is prime, then every number from 1 to $p-1$ is relatively prime to it. So, using the Fermat-Euler Theroem, $a^{\varphi(n)} \equiv 1$ if $1 \leq a \leq p-1$. We see that every term in the sum becomes congruent to 1, and $\sum_1^{p-1} 1 = p-1 \equiv -1 \pmod p $.
I don't know what to do if $p-1 \nmid n $. I've tried taking a primitive root mod p, but I got stuck.Any help or tip would be much aprecciated.
To elaborate on my comment:
Suppose that $p-1\nmid n$. Then let $g$ be a primitive root $\pmod p$. It follows that $g^n\not \equiv 1 \pmod p$. Also, $g$ is clearly invertible $\pmod p$. That implies that the list $\{g\times 1, g\times 2, \cdots, g\times (p-1)\}$ is a full list of the non-zero residues $\pmod p$.
Thus $$S_n\equiv (g\times 1)^n+(g\times 2)^n+\cdots +(g\times (p-1))^n\equiv g^nS_n \pmod p$$
But then, as $g^n\not \equiv 1$ we see that $S_n\equiv 0\pmod p$ as desired.