Skip to main content

Discrete Mathematical Structures

Subsection 5.4.3 Fermat’s little theorem and Euler’s generalization

Proof.

We prove that if \(1\le a\lt p\) then \(a^{p - 1} \equiv 1 \pmod p\text{.}\)
First we proof that if \(1\le x \le p-1\) and \(1\le y \le p-1\) with \(x\ne y\) then \((a\cdot x) \bmod p\ne (a \cdot y) \bmod p\) by contradiction.
Suppose \((a \cdot x) \bmod p = (a \cdot y) \bmod p\text{.}\) Then \(a \cdot (x-y)\bmod p = 0\text{.}\) Because \(p\) is prime and \(p\nmid a\) we have that \(p\mid a(x−y)\) implies \(p\mid (x−y)\text{.}\) Because \(1\le x \le p-1\) and \(1\le y \le p-1\) and \(x\ne y\) we have \(-(p-1) \lt x-y \lt p-1\text{.}\) Thus \(x-y=0\text{,}\) which contradicts \(x\ne y\text{.}\)
Because of the above we have
\begin{equation*} \{1,\dots,p-1\}=\bigl\{(a\!\cdot\!1) \bmod p,\dots,\bigl(a\!\cdot\!(p-1)\bigr) \mod p\bigr\}. \end{equation*}
Thus
\begin{equation*} \left(\prod_{b=1}^{p-1}b\right)\bmod p=\left(\prod_{b=1}^{p-1}a\!\cdot\!b\right)\mod p=\left(a^{p-1}\!\cdot\!\prod_{b=1}^{p-1}b\right)\mod p. \end{equation*}
Therefore \(a^{p-1} \bmod p = 1\text{.}\)
Fermat’s Little Theorem 5.4.3.1 is easily generalized to all integers. For a prime number \(p\) and an integer \(a\) we obtain \(a^p\bmod p = a\)

Example 5.4.3.2. Small example for Little Fermat.

Let \(p=5\) and \(x=2\text{.}\) Then \(2^{5-1}\bmod 5=16\bmod 5=1\text{.}\)
Let \(p=5\) and \(x=3\text{.}\) Then \(3^{5-1}\bmod 5=81\bmod 5=1\text{.}\)
With Euler’s \(\phi\) function and the Chinese Remainder Theorem 5.4.2.1 we can generalize Fermat’s Little Theorem 5.4.3.1 to composite moduli

Example 5.4.3.4. Little Fermat’s power.

Compute \(8^{222} \bmod{11}\text{.}\)
Solution.
Note that \(11\) is prime and \(\gcd(11, 8) = 1\text{.}\) Since \(11-1 = 10\text{,}\) Fermat’s little theorem implies \(8^{10} \equiv 1 \pmod{11}\text{.}\) We rewrite the exponent \(222\) as
\begin{equation*} 222 = 22 \cdot 10 + 2 \end{equation*}
and use properties of exponents to get
\begin{equation*} 8^{222} \equiv 8^{22 \cdot 10 + 2} \equiv 1^{22} \cdot 8^2 \pmod{11} \equiv 9 \pmod{11}. \end{equation*}
Thus \(8^{222} \bmod{11} = 9\text{.}\)