# Remainder of Fermat's little theorem sum

With p being a prime number, what is the remainder of $$\sum_{k=1}^{p-1} {k^{p-1}}$$ divided by p ?

I know that Fermat's little theorem states that for a prime number p, and a number A that is not divisible by p: $${A^{p-1}}≡ 1\mod p$$

So I'm thinking that the remainder would be 1, what am I missing here?

Any guidance, clues or solutions are much appreciated, thanks!

• Shouldn't the remainder be $-1$? – Mostafa Ayaz Aug 25 '19 at 19:06
• Welcome to Mathematics Stack Exchange. You have to sum $1$, $p-1$ times – J. W. Tanner Aug 25 '19 at 19:27
• Inves I edited Mike's complete answer just in case you missed that the sum which is $p-1 \equiv -1 (mod p)$, so the remainder you're looking for is $-1$. – jacopoburelli Aug 25 '19 at 19:30

So I'm thinking that the remainder would be 1, what am I missing here?

What you are missing, is the basic rule of $$\underset{p-1 \text{ times}}{\underbrace{1+1+\cdots+1+1}}=p-1$$ still working in modular arithmetic. It simply wraps if it gets too big, which this sum isn't.

• thank you, that explains the sum. but how would one solve for the sum p-1 divided by p? would the remainder then be p-1 aswell, since p-1 < p ? – Inves Aug 26 '19 at 12:05
• that is correct. – user645636 Aug 26 '19 at 12:05

The logic seems fine, but I don't think your conclusion follows from it. From what you've shown, $$\sum_{k=1}^{p-1}k^{p-1}\equiv\sum_{k=1}^{p-1}1 = p-1 \equiv -1\pmod p$$

I'm pretty sure you don't get $$1$$ from simplifying that.

• only in the special case of $p=2$ – user645636 Aug 25 '19 at 23:28
• -1 is an alternative version of $p-1$ in modular arithmetic. We say they are congruent, or in the same modular congruence class as each other. this happens because their difference is a multiple of $p$ – user645636 Aug 26 '19 at 12:07