Prove that $S_k(p)= \begin{cases} -1, & \text{if $(p-1)\mid k$ } \\ 0, & \text{otherwise} \end{cases}$ in $\Bbb Z_p$ Consider $\Bbb Z_p= \Bbb Z/{p \Bbb Z}$ where $p$ is an odd prime.
Now denote $S_k(p)= \sum _{j=0}^{p-1} j^k$ in $\Bbb Z_p$

The problem is to prove that $S_k(p)= \begin{cases}
-1,  & \text{if $(p-1)\mid k$ } \\
0, & \text{otherwise}
\end{cases}$ in $\Bbb Z_p$

Now we know $\Bbb Z_p^*$ is a cyclic group of order $p-1$, so in the first case if we have $k=a(p-1)$, then $\forall j \in \Bbb Z_p^*$ we have $j^k=j^{(p-1)a}=1$. Hence $S_k(p)=p-1=-1$ in $\Bbb Z_p$
if $(p-1)$ does not divide $k$ then I am having problem.
If $\gcd(p-1,k)=1$ then $S_k(p)= \sum _{j=0}^{p-1} j=p(p-1)/2=0$ in $\Bbb Z_p$
But for the other cases?? Please help and explain in details.
 A: Lemma(I): 
Let $p$ to be an odd prime, 
then $\big(  \mathbb{Z}_p^* , .  \big)$ is a cyclic group.

Lemma(II): 
For every $i \in \mathbb{Z}_p^*$; 
we have: $i \mathbb{Z}_p^* = \mathbb{Z}_p^*$.

Lemma(III): 
Let $p$ to be an odd prime, 
and let $k$ to be any arbitrary integer.


*

*If $p-1 \mid k$; 
then for every $j \in \mathbb{Z}_p^*$; 
we have: 
$j^k \overset{p}{\equiv} 1$. 

*If $p-1 \nmid k$; 
then there exists $l \in \mathbb{Z}_p^*$; 
such that: 
$l^k \overset{p}{\ncong} 1$. 

Proof: 


*

*The first statement is the trivial result of fermat's little theorem.

*Second statement: 
Let $\varepsilon$ to be a generator of 
$\big(  \mathbb{Z}_p^* , .  \big)$;
and let $d:=\gcd(k,p-1)$.
Also let $t:=\dfrac{p-1}{d}$;
then it is easy to check that 
for every $r$, with $\gcd(r,t)=1$;
we have: 
$(\varepsilon^r)^k \overset{p}{\ncong} 1$.

Lemma(IV): 
Let $G$ be any group 
and $a \in G$ any element of finite order. Then we have: 
$$\text{ord}(a^t)=\dfrac{\text{ord}(a)}{\gcd(\text{ord}(a),t)}.$$ 






*

*If $p-1 \mid k$; 
then for every $j \in \mathbb{Z}_p^*$; 
we have: 
$j^k \overset{p}{\equiv} 1$. 
So the sum 
$ 
{\sum}_{j \in \mathbb{Z}_p^*}j^k= 
{\sum}_{j \in \mathbb{Z}_p^*}  1= 
p-1=-1.$ 

*If $p-1 \nmid k$; 
then there exists $l \in \mathbb{Z}_p^*$; 
such that: 
$l^k \overset{p}{\ncong} 1$. 
Notice that: 
$$ 
\color{Blue}{ 
     {\sum}_{ j \in \mathbb{Z}_p^*} j^k     }= 
     {\sum}_{lj \in \mathbb{Z}_p^*} (lj)^k  = 
     {\sum}_{ j \in \mathbb{Z}_p^*} l^kj^k  = 
\color{Red}{l^k}  
\color{Blue}{ 
     {\sum}_{ j \in \mathbb{Z}_p^*}    j^k  } 
\\ 
\Longrightarrow 
(1-\color{Red}{l^k}  )
\color{Blue}{ 
     {\sum}_{ j \in \mathbb{Z}_p^*}    j^k  } = 
0 ; 
$$ 
but notice that 
$(1-\color{Red}{l^k}  )$ is not zero;
which implies that: 
$\color{Blue}{ 
     {\sum}_{ j \in \mathbb{Z}_p^*}    j^k  }=0$. 
