By the division algorithm,
\(a\) is congruent modulo
\(p\) to an integer
\(r\) in the range
\(0 \leq r \lt p-1\text{.}\) Because
\(a \equiv r \pmod p\) and
\(a^p \equiv r^p \pmod p\text{,}\) we need to prove
\(r \equiv r^p \pmod p\text{.}\)
Since \(r\) is non-negative, we can prove the statment by induction. If \(r = 0\text{,}\) then \(r^p = 0^p = 0 = r\text{.}\) Now suppose that the statement is true for some non-negative integer \(r\) and we want to prove it for \(r+1\text{.}\) By the binomial formula,
\begin{equation*}
(r+1)^p = \sum_{i=0}^p \binom{p}{i} r^i, \quad\mbox{where}\quad \binom{p}{i} = \frac{p!}{i!(p-i)!}\text{.}
\end{equation*}
The numerator \(p!\) is clearly divisible by \(p\text{.}\) When \(1 \leq i \leq p-1\text{,}\) then the denominator \(i!(p-i)!\) is a product of integers less than \(p\) and so not a multiple of \(p\) by the contrapositive of Euclidโs Lemma. Also by Euclidโs Lemma, the fraction \(p!/(i!(p-i)!)\) is therefore divisible by \(p\) for \(1 \leq i \leq p-1\text{.}\) Thus, in the summation above, all the terms are divisible by \(p\) except for \(i = 0\) and \(i = p\text{,}\) and so,
\begin{align*}
(r+1)^p = \sum_{i=0}^p \binom{p}{i} r^i \amp\equiv r^0 + r^p \pmod p\\
\amp= 1 + r^p\\
\amp\equiv r + 1 \pmod p
\end{align*}
by the induction hypothesis. Therefore, weโve shown that \(r^p \equiv r \pmod p\) for all \(r \geq 0\) and thus \(a^p \equiv a \pmod p\) for all integers \(a\text{.}\)