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

modular arithmeticnumber theory

I'm currently working on the following exercise:

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

What I'm doing is the following:

$$m(m^{p-1}+(p-1)!)\equiv 0\mod p$$
$$m((1)+(-1))\equiv 0\mod p$$
$$m(0)\equiv 0 \mod p$$
$$0 \equiv 0 \mod p.$$

Is a valid proof? Am I missing something? Any hint or help will be really appreciated.

Best Answer

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$.