# Let $p$ be a prime. Compute $1^k + 2^k + \ldots + (p-1)^k \pmod{p}$. [duplicate]

This question already has an answer here:

An exercise at the end of a chapter on primitive roots asked me to compute $1^k + 2^k + \ldots + (p-1)^k \pmod{p}$ for any positive integer $k$ and any prime $p$. Clearly, if $k$ is odd, the expression is congruent to $0$ modulo $p$. But how can I even approach this problem if $k$ is even? And how do primitive roots apply? Hints would be greatly appreciated.

## marked as duplicate by Stefan4024, Jack D'Aurizio number-theory StackExchange.ready(function() { if (StackExchange.options.isMobile) return; $('.dupe-hammer-message-hover:not(.hover-bound)').each(function() { var$hover = $(this).addClass('hover-bound'),$msg = $hover.siblings('.dupe-hammer-message');$hover.hover( function() { $hover.showInfoMessage('', { messageElement:$msg.clone().show(), transient: false, position: { my: 'bottom left', at: 'top center', offsetTop: -7 }, dismissable: false, relativeToBody: true }); }, function() { StackExchange.helpers.removeMessages(); } ); }); }); Aug 9 '18 at 23:12

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

## 1 Answer

apply Fermat's little theorem it says

$a^p \equiv \pmod p$

If $p-1 \mid k$ then by Fermat Little Theorem $a^k \equiv 1 \pmod p$

• I don't see this. The exponents in the sum are $k$, not $p.$ – saulspatz Aug 9 '18 at 23:03
• sorry I made a mistake – Deepesh Meena Aug 9 '18 at 23:03