You are here

Search form

Navigation

Fermat's Little Theorem

We've seen how to solve linear congruences using the Euclidean Algorithm, what if we now wanted to look at higher-order congruences -- ones that involve squares, cubes, and other higher powers of a variable in a given modulus. How do higher powers behave$\pmod{m}$?

Consider $a, a^2, a^3, ... \pmod{m}$ for various values of $a$ and $m$, as shown below. Do you notice anything?

One thing that should stand out is that each has a column almost entirely filled with 1's (with the exception of the very top entry, which is zero). Furthermore, there seems to be a pattern as to which column this is. This observation is known as Fermat's Little Theorem (although it was first proven by Leibniz).

More generally, if for some prime $p$ and $a \not\equiv 0\pmod{p}$, we have $a, 2a, 3a, ..., (p-1)a\pmod{p}$ identical in values, but possibly not order, to $1, 2, 3, ..., (p-1)\pmod{p}$, then
$$(a \cdot 1)(a \cdot 2)(a \cdot 3) \cdots (a \cdot (p-1)) \equiv 1 \cdot 2 \cdot 3 \cdots (p-1) \pmod{p}$$
which similarly gives us
$$a^{p-1} (p-1)! \equiv (p-1)! \pmod{p}$$
As $1,2,3,...,(p-1)$ are all relatively prime to $p$, we are free to cancel these factors from both sides as was done above to arrive at
$$a^{p-1} \equiv 1 \pmod{p},$$
which is what we hope to show.

So it all comes down to whether or not we can prove that $a, 2a, 3a, ..., (p-1)a\pmod{p}$ are identical in values, but possibly not order, to $1, 2, 3, ..., (p-1)\pmod{p}$.

First, note that we have $(p-1)$ values in the list $a, 2a, 3a, ..., (p-1)a\pmod{p}$. Since there are only $(p-1)$ distinct nonzero values$\pmod{p}$, showing all of the multiples of $a$ above are distinct and nonzero should be sufficient to guarantee the result.

Showing that these values are nonzero is trivial as $a \not\equiv 0\pmod{p}$.

To show they are distinct, suppose any two distinct values above are congruent$\pmod{p}$:
$$i \cdot a \equiv j \cdot a\pmod{p}$$
Since $a \not\equiv 0\pmod{p}$ and $p$ is prime, $a$ must be relatively prime to $p$, which allows us to cancel $a$ from both sides to obtain $i \equiv j\pmod{p}$ and consequently
$$i-j \equiv 0\pmod{p}$$
Now consider the size of $|i-j|$. Since $1 \le i,j \le (p-1)$, it must be true that $|i-j| \lt p-1$. As zero is the only multiple of $p$ with magnitude less than $(p-1)$, we have $i=j$, which then contradicts the fact that $ia$ and $ja$ were distinct values $\pmod{p}$.