Skip to main content
Contents Index
Dark Mode Prev Up Next
\(\newcommand{\im}{{\mathrm{im}}}
\newcommand{\given}{{\, :\,}}
\newcommand{\hanoi}{\mathrm{hanoi}}
\newcommand{\lcm}{{\mathrm{lcm}}}
\newcommand{\ID}{{\mathrm{ID}}}
\newcommand{\chr}{{\mathtt{chr}}}
\newcommand{\ord}{{\mathtt{ord}}}
\newcommand{\set}[1]{\left\lbrace #1 \right\rbrace}
\newcommand{\seq}[2]{( #1 )_{#2}}
\newcommand{\gr}[1]{\left( #1 \right)}
\newcommand{\abs}[1]{\left| #1 \right|}
\newcommand{\size}[1]{\# #1}
\newcommand{\id}[1]{\mathrm{id}_{#1}}
\newcommand{\ip}[1]{\left\langle #1 \right\rangle}
\newcommand{\floor}[1]{\left\lfloor #1\right\rfloor}
\newcommand{\ceiling}[1]{\left\lceil #1\right\rceil}
\newcommand{\indemph}[1]{{\textbf{\emph{#1}}\index{#1}}}
\renewcommand{\implies}{\to}
\renewcommand{\iff}{\leftrightarrow}
\newcommand{\lxor}{\oplus}
\newcommand{\cP}{\wp}
\newcommand{\pset}{\cP}
\newcommand{\ZZ}{\mathbb{Z}}
\newcommand{\QQ}{\mathbb{Q}}
\newcommand{\NN}{\mathbb{N}}
\newcommand{\CC}{\mathbb{C}}
\newcommand{\RR}{\mathbb{R}}
\newcommand{\barr}[1]{\overline{#1}}
\newcommand{\sage}{\textsc{Sage}}
\newcommand{\magma}{\textsc{Magma}}
\newcommand{\bob}{\text{Bob}}
\newcommand{\true}{\text{T}}
\newcommand{\false}{\text{F}}
\newcommand{\ahat}{\hat{a}}
\newcommand{\ah}{\ahat}
\newcommand{\bhat}{\hat{b}}
\newcommand{\abar}{\bar{a}}
\newcommand{\cA}{\mathcal{A}}
\newcommand{\cF}{\mathcal{F}}
\newcommand{\cW}{\mathcal{W}}
\newcommand{\todo}[1]{{\color{red} TODO: #1}}
\renewcommand{\div}{\operatorname{div}}
\newcommand{\gexp}[3]{#1^{#2 #3}}
\newcommand{\gexpp}[3]{\displaystyle\left(#1\right)^{#2 #3}}
\newcommand{\glog}[3]{\log_{#1}^{#3}#2}
\def\dbend{{!!!}}
\newcommand{\lt}{<}
\newcommand{\gt}{>}
\newcommand{\amp}{&}
\definecolor{fillinmathshade}{gray}{0.9}
\newcommand{\fillinmath}[1]{\mathchoice{\colorbox{fillinmathshade}{$\displaystyle \phantom{\,#1\,}$}}{\colorbox{fillinmathshade}{$\textstyle \phantom{\,#1\,}$}}{\colorbox{fillinmathshade}{$\scriptstyle \phantom{\,#1\,}$}}{\colorbox{fillinmathshade}{$\scriptscriptstyle\phantom{\,#1\,}$}}}
\)
Subsection 5.4.3 Fermat’s little theorem and Euler’s generalization
Theorem 5.4.3.1 . Fermat’s little theorem.
Let
\(p\) be a prime number and
\(a\) an integer. If
\(p \nmid a\text{,}\) then
\(a^{p - 1} \equiv 1 \pmod p\text{.}\)
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{.}\)
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{.}\)
Theorem 5.4.3.3 . Euler’s generalization.
Let
\(m\) be an integer greater than one and let
\(a\) be an integer. If
\(\gcd(a,m)=1 \text{,}\) then
\(a^{\phi(m)} \equiv 1 \pmod m\text{.}\)
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{.}\)