I'm doing exercises in an elementary number theory book, and I'm asked to prove the claim, for prime $p$:
If $2^m\not\equiv 1\pmod{p}$, then
$1^m+2^m+\cdots +(p-1)^m\equiv 0\pmod{p}$
It is quite clear to me why this is true for odd $m$, but I don't see why it works when $m$ is even. For $m$ odd, everything cancels in pairs: $a^m+(p-a)^m\equiv 0$; great.
Looking at examples where $m$ is even, it appears to be true, even when $2^m\equiv 1$, as long as $m<p-1$, where it obviously fails. (See, for example, $p=17, m=8$.)
I observe that, in the even case, it suffices to examine the sum from $1$ to $\frac{p-1}{2}$, because the second half of the residue system just repeats this, and $0$ is the unique solution of $2x\equiv 0$.
So, can anyone give me a hint on this, and is the condition $2^m\not\equiv 1$ really the right condition? Thanks in advance for any insights.
Since the other two answers use material far beyond what’s necessary for the question, this question deserves a more elementary answer.
It isn’t explicitly stated in the question, but the claim is false for $p=2$ (since OP mentions $(p-1)/2$ they are likely aware of this already). So we assume $p$ to be odd, which we use many times in what follows.
Let $S = 1^m + 2^m + \cdots + (p-1)^m$ be the sum in question. Now consider $$2^m S = 2^m + 4^m + \cdots + (2p-2)^m.$$
We split this sum into the left and right halves
$$[2^m + 4^m + \cdots + (p-1)^m] \\ + [(p+1)^m + (p+3)^m+\cdots+(2p-2)^m],$$ which is congruent mod $p$ to
$$[2^m + 4^m + \cdots + (p-1)^m \\ + [1^m + 3^m + \cdots + (p-2)^m].$$
We quickly see that this is exactly the same sum as $S$ with the even and odd terms separated out. Thus $2^m S \equiv S \pmod p$, so that $(2^m-1)S$ is divisible by $p$. By assumption, the first factor is not divisible by $p$ so it must be $S$ that’s divisible by $p$.
There is absolutely no need for primitive roots or elaborate combinatorial identities here. Some basic group theory is lurking unspoken in the background, but we were able to complete the entire argument without even appealing to the existence of modular inverses! I think this answers the OP’s question of why the problem seems unnecessarily specific: specializing the problem to this extent affords a very elementary proof.
More generally, we can use this argument in other rings where there is an invertible multiplier $g$ such that $g^m-1$ is also invertible (note that we are free to have the sum include or exclude noninvertible indices). But this takes a little bit more sophistication to see that the action of multiplying by $g$ permutes the elements, whereas in the case of $g=2$ it resolves into just even and odd terms.