Skip to main content \(\newcommand{\longdivision}[2]{#1\big)\!\!\overline{\;#2}}
\newcommand{\mlongdivision}[2]{\longdivision{#1}{#2}}
\renewcommand{\emptyset}{\{\}}
\newcommand{\blanksp}{\underline{\hspace{.25in}}}
\newcommand{\set}[1]{\left\{#1\right\}}
\newcommand{\cspace}{-}
\newcommand{\Ta}{\mathtt{a}}
\newcommand{\Tb}{\mathtt{b}}
\newcommand{\Tc}{\mathtt{c}}
\newcommand{\Td}{\mathtt{d}}
\newcommand{\Te}{\mathtt{e}}
\newcommand{\Tf}{\mathtt{f}}
\newcommand{\Tg}{\mathtt{g}}
\newcommand{\Th}{\mathtt{h}}
\newcommand{\Ti}{\mathtt{i}}
\newcommand{\Tj}{\mathtt{j}}
\newcommand{\Tk}{\mathtt{k}}
\newcommand{\Tl}{\mathtt{l}}
\newcommand{\Tm}{\mathtt{m}}
\newcommand{\Tn}{\mathtt{n}}
\newcommand{\To}{\mathtt{o}}
\newcommand{\Tp}{\mathtt{p}}
\newcommand{\Tq}{\mathtt{q}}
\newcommand{\Tr}{\mathtt{r}}
\newcommand{\Ts}{\mathtt{s}}
\newcommand{\Tt}{\mathtt{t}}
\newcommand{\Tu}{\mathtt{u}}
\newcommand{\Tv}{\mathtt{v}}
\newcommand{\Tw}{\mathtt{w}}
\newcommand{\Tx}{\mathtt{x}}
\newcommand{\Ty}{\mathtt{y}}
\newcommand{\Tz}{\mathtt{z}}
\newcommand{\So}{\Tf}
\newcommand{\Sno}{\Tg}
\newcommand{\Si}{\Th}
\newcommand{\Sni}{\Tj}
\newcommand{\N}{\mathbb{N}}
\newcommand{\Z}{\mathbb{Z}}
\newcommand{\W}{\mathbb{W}}
\newcommand{\ZZ}{\Z}
\newcommand{\PP}{\mathbb{P}}
\newcommand{\Q}{\mathbb{Q}}
\newcommand{\R}{\mathbb{R}}
\newcommand{\RR}{\R}
\newcommand{\F}{\mathbb{F}}
\newcommand{\A}{\mathbb{A}}
\newcommand{\abs}[1]{|#1|}
\newcommand{\fmod}{\bmod}
\newcommand{\fdiv}{\,\mathrm{div}\,}
\newcommand{\lcm}{\mathrm{lcm}}
\newcommand{\id}{\mathrm{id}}
\newcommand{\nr}[1]{\##1}
\newcommand{\gexp}[3]{#1^{#2 #3}}
\newcommand{\gexpp}[3]{\displaystyle\left(#1\right)^{#2 #3}}
\newcommand{\glog}[3]{\log_{#1}^{#3}#2}
\newcommand{\sol}[1]{{\color{blue}\textit{#1}}}
\newcommand{\gro}[1]{{\color{gray}#1}}
\newcommand{\todo}[1]{{\color{purple}TO DO: #1}}
\newcommand{\fixme}[1]{{\color{red}FIX ME: #1}}
\newcommand{\checkme}[1]{{\color{green}CHECK ME: #1}}
\newcommand{\degre}{^\circ}
\newcommand{\vect}[1]{\overrightarrow{#1}}
\newcommand{\nix}{}
\newcommand{\cox}[1]{\fcolorbox[HTML]{000000}{#1}{\phantom{M}}}
\newcommand{\tox}[1]{\texttt{\##1} \amp \cox{#1}}
\newcommand{\ttx}[1]{\texttt{\##1}}
\newcommand{\mox}[1]{\mathtt{\##1}}
\newcommand{\xx}{\mathtt{\#}}
\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\,}$}}}
\)
Section 4.2 Greatest Common Divisors
In the video in
Figure 4.6 we recall the definition of divisibility and give an introduction to greatest common divisors.
Figure 4.6. Greatest Common Divisors by Matt Farmer and Stephen Steward The definition of the greatest common divisor of two integers is intuitive. To make it unique, we require it to be positive.
Definition 4.7 .
Let
\(a\) and
\(b\) be integers. The greatest natural number
\(g\) that divides both
\(a\) and
\(b\) is called the
greatest common divisor of
\(a\) and
\(b\) and is denoted by
\(\gcd(a,b)\text{.}\)
We say
\(a\) and
\(b\) are
coprime if
\(\gcd(a,b) = 1\text{.}\)
In the definition the order of
\(a\) and
\(b\) does not matter. We have:
Theorem 4.8 .
In our first example we find a greatest common divisor of two integers by checking all divisors of both numbers.
Example 4.9 . Greatest common divisor of \(12\) and \(42\) .
We find the greatest common divisor of \(12\) and \(42\text{.}\) As all divisors of 12 are less than or equal to 12, we only have to check numbers less than 12.
5 does not divide 12 or 42
7 does not divide 12, but does divide 42
8 does not divide 12 or 42
9 does not divide 12 or 42
10 does not divide 12 or 42
11 does not divide 12 or 42
Thus the greatest integer that divides both 12 and 42 is 6, that is,
\(\gcd(12,42)=6\text{.}\)
We now consider some special cases, in which we can directly read of the greatest common divisor.
Example 4.10 . Greatest common divisor special cases.
We give the greatest common divisor in some special cases. Let \(a\) be a natural number. Then
\(\gcd(a,a)=a\text{,}\) as the largest natural number that divides
\(a\) is
\(a\text{.}\)
\(\gcd(0,a)=a\text{,}\) as
\(0\) is divisible by all natural numbers
\(a\text{.}\)
\(\gcd(1,a)=1\text{,}\) as the largest divisor of
\(1\) is
\(1\) and all natural numbers
\(a\) are divisible by
\(1\text{.}\)
Our next goal is to find an efficient method for finding greatest common divisors in general. Recall that remainder of division of
\(a\) and
\(b\) is
\(a - (b\cdot q)\) where
\(q := a \fdiv b\text{.}\) Theorem 4.11 tells us that we can use the remainder to help us find the greatest common divisor.
Theorem 4.11 .
Let \(g\) be a natural number and let \(a\text{,}\) \(b\text{,}\) and \(q\) be integers.
If
\(g\) divides
\(a\) and
\(g\) divides
\(b\) then
\(g\) also divides
\(a-(b\cdot q)\text{.}\)
If
\(g\) divides
\(a-(b\cdot q)\) and
\(g\) divides
\(b\) then
\(g\) also divides
\(a\text{.}\)
\(\gcd(a-(b\cdot q),b)=\gcd(a,b)\text{.}\)
\(\gcd(a\fmod b,b)=\gcd(a,b)\text{.}\)
Proof.
As \(g\) divides \(a\) there exists an integer \(s\) such that \(a=g\cdot s\) and as \(g\) divides \(b\) there exists an integer \(t\) such that \(b=g\cdot t\text{.}\) We now have
\begin{equation*}
a-(b\cdot q)=(g\cdot s)-((g\cdot t) \cdot q)=g\cdot(s-(t\cdot q))\text{.}
\end{equation*}
Thus \(a-(b\cdot q)\) is a multiple of \(g\) which means that \(g\) divides \(a-(b\cdot q)\text{.}\)
As \(g\) divides \(a-(b\cdot q)\) there exists an integer \(s\) such that \(a-(b\cdot q)=g\cdot s\) and as \(g\) divides \(b\text{,}\) there exists an integer \(s\) such that \(b=g\cdot t\text{.}\) We now have
\begin{equation*}
a=(a-(b\cdot q))+ (b\cdot q)= (g\cdot s)+( (g\cdot t)\cdot q)=g\cdot(s+(t\cdot q))
\end{equation*}
Thus \(a\) is a multiple of \(g\) which means that \(g\) divides \(a\text{.}\)
By
Item 1 all natural numbers
\(g\) that divide
\(a\) and
\(b\) also divide
\(a-(b\cdot q)\text{.}\) By
Item 2 all natural numbers
\(g\) that divide
\(a-(b\cdot q)\) and
\(b\) also divide
\(a\text{.}\) Thus the common divisors of
\(a\) and
\(b\) and the common divisors of
\(a-(b\cdot q)\) are the same. So, in particular, the greatest common divisor of
\(a\) and
\(b\) is equal to the greatest common divisor of
\(a-(b\cdot q)\) and
\(b\text{.}\)
For
\(q:=a \fdiv q\) we have
\(a \fmod b=a-(b\cdot q)\text{.}\) With
Item 3 we get
\begin{equation*}
\gcd(a\fmod b,b) = \gcd(a-(b\cdot q),b) = \gcd(a,b)\text{.}
\end{equation*}
We now repeatedly apply
Theorem 4.11 Item 4 to find the greatest common divisor of two integers.
Example 4.12 . Compute \(\gcd(51,15)\) using \(\gcd(a,b) = \gcd(a\fmod b,b)\) .
Let
\(a:=51\) and
\(b:= 15\text{.}\) We find
\(\gcd(a,b)\text{.}\) With
Theorem 4.11 3. 4 we get
\begin{equation*}
\gcd(51,15)=\gcd(51\fmod 15,15)=\gcd(6,15)\text{.}
\end{equation*}
\begin{equation*}
\gcd(6,15)=\gcd(15,6)\text{.}
\end{equation*}
\begin{equation*}
\gcd(15,6)=\gcd(15 \fmod 6,6)=\gcd(3,6)\text{.}
\end{equation*}
\begin{equation*}
\gcd(3,6)=\gcd(6,3)\text{.}
\end{equation*}
\begin{equation*}
\gcd(6,3)=\gcd(6\fmod 3,3)=\gcd(0,3)\text{.}
\end{equation*}
\begin{equation*}
\gcd(0,3)=3\text{.}
\end{equation*}
We summarize the steps above. We have found:
\begin{align*}
\gcd(51,15) \amp =\gcd(51-(15\cdot 3),15) \\
\amp = \gcd(6,15)\\
\amp =\gcd(15,6)\\
\amp=\gcd(3,6)\\
\amp=\gcd(6,3)\\
\amp=\gcd(0,3)=3\text{.}
\end{align*}
That is,
\(\gcd(51,15)=3\)