Show that for any prime $p$ and any integer $m$, $m^p + (p − 1)! m$ is divisible by $p$.

Show that for every prime number $p$ and every integer $m$, the number $mp+(p−1)!m$ is divisible by $p$.

This can be proved via two theorems: Fermat's Little Theorem and Wilson's Theorem.

$\,m^p+(p-1)!m \;=\; m^p-m+(p-1)!m+m \;=\; m^p-m+m((p-1)!+1)$

By Fermat's little theorem, $\,m^p-m\,$ is an integer multiple of $p$, since $p$ is prime.

By Wilson's Theorem, $\, (p-1)!+1\,$ is an integer multiple of $\,p\,$, since $\,p\,$ is prime.

So, for some $\, k,\,l \in \mathbb{Z}\text{,}\,$ we have $$m^p-m+m((p-1)!+1) \;=\; kp + m(lp) \;=\; p(k+ml)\text{.}$$

Thus $\,m^p+(p−1)!m\,$ is divisible by $p$.


I believe the error in your proof came from assuming that $\,m^{p-1}\equiv1\,(\text{mod}\; p)\text{.}\,$ This is only true if we assume $m$ is not divisible by $p$.


Let $p$ be a prime number and $m$ an integer.

By Fermat's little theorem, $m^p \equiv m \pmod p$, and by Wilson's theorem $(p-1)! \equiv -1 \pmod p$.

Therefore, $ m^p + (p-1)!m \equiv m+(-1) \times m \equiv m-m \equiv 0 \pmod p$,

so $p$ divides $m^p+(p-1)!m.$