Skip to main content
\(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\)
Mathematics LibreTexts

1.5: The Greatest Common Divisor

[ "article:topic", "Greatest Common Divisor", "authorname:wraji", "showtoc:no" ]
  • Page ID
    8821
  • \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)

    \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)

    In this section we define the greatest common divisor (gcd) of two integers and discuss its properties. We also prove that the greatest common divisor of two integers is a linear combination of these integers.

    Two integers \(a\) and \(b\), not both \(0\), can have only finitely many divisors, and thus can have only finitely many common divisors. In this section, we are interested in the greatest common divisor of \(a\) and \(b\). Note that the divisors of \(a\) and that of \(\mid a \mid\) are the same.

    The greatest common divisor of two integers \(a\) and \(b\) is the greatest integer that divides both \(a\) and \(b\).

    We denote the greatest common divisor of two integers \(a\) and \(b\) by \((a,b)\). We also define \((0,0)=0\).

    Note that the greatest common divisor of 24 and 18 is 6. In other words \((24,18)=6\).

    There are couples of integers (e.g. 3 and 4, etc...) whose greatest common divisor is 1 so we call such integers relatively prime integers.

    Two integers \(a\) and \(b\) are relatively prime if \((a,b)=1\).

    The greatest common divisor of 9 and 16 is 1, thus they are relatively prime.

    Note that every integer has positive and negative divisors. If \(a\) is a positive divisor of \(m\), then \(-a\) is also a divisor of \(m\). Therefore by our definition of the greatest common divisor, we can see that \((a,b)=(\mid a\mid, \mid b\mid)\).

    We now present a theorem about the greatest common divisor of two integers. The theorem states that if we divide two integers by their greatest common divisor, then the outcome is a couple of integers that are relatively prime.

    If \((a,b)=d\) then \((a/d,b/d)=1\).

    We will show that \(a/d\) and \(b/d\) have no common positive divisors other than \(1\). Assume that \(k\) is a positive common divisor such that \(k\mid a/d\) and \(k\mid b/d\). As a result, there are two positive integers \(m\) and \(n\) such that \[a/d=km \hspace{0.3 cm}\mbox{and} \ \ b/d=kn\] Thus we get that \[a=kmd \hspace{0.3 cm}\mbox{and} \ \ b=knd.\] Hence \(kd\) is a common divisor of both \(a\) and \(b\). Also, \(kd\geq d\). However, \(d\) is the greatest common divisor of \(a\) and \(b\). As a result, we get that \(k=1\).

    The next theorem shows that the greatest common divisor of two integers does not change when we add a multiple of one of the two integers to the other.

    Let \(a,b\) and \(c\) be integers. Then \((a,b)=(a+cb,b)\).

    We will show that every divisor of \(a\) and \(b\) is also a divisor of \(a+cb\) and \(b\) and vise versa. Hence they have exactly the same divisors. So we get that the greatest common divisor of \(a\) and \(b\) will also be the greatest common divisor of \(a+cb\) and \(b\). Let \(k\) be a common divisor of \(a\) and \(b\). By Theorem [thm4], \(k \mid (a+cb)\) and hence \(k\) is a divisor of \(a+cb\). Now assume that \(l\) is a common divisor of \(a+cb\) and \(b\). Also by Theorem [thm4] we have , \[l\mid ((a+cb)-cb)=a.\] As a result, \(l\) is a common divisor of \(a\) and \(b\) and the result follows.

    Notice that \((4,14)=(4,14-3\cdot 4)=(4,2)=2\).

    We now present a theorem which proves that the greatest common divisor of two integers can be written as a linear combination of the two integers.

    [thm9] The greatest common divisor of two integers \(a\) and \(b\), not both \(0\) is the least positive integer such that \(ma+nb=d\) for some integers \(m\) and \(n\).

    Assume without loss of generality that \(a\) and \(b\) are positive integers. Consider the set of all positive integer linear combinations of \(a\) and \(b\). This set is non empty since \(a=1\cdot a+0\cdot b\) and \(b=0\cdot a+1\cdot b\) are both in this set. Thus this set has a least element \(d\) by the well-ordering principle. Thus \(d=ma+nb\) for some integers \(m\) and \(n\). We have to prove that \(d\) divides both \(a\) and \(b\) and that it is the greatest divisor of \(a\) and \(b\).

    By the division algorithm, we have \[a=dq+r, \ \ \ 0\leq r<d.\] Thus we have \[r=a-dq=a-q(ma+nb)=(1-qm)a-qnb.\] We then have that \(r\) is a linear combination of \(a\) and \(b\). Since \(0\leq r<d\) and \(d\) is the least positive integer which is a linear combination of \(a\) and \(b\), then \(r=0\) and \(a=dq\). Hence \(d\mid a\). Similarly \(d\mid b\). Now notice that if there is a divisor \(c\) that divides both \(a\) and \(b\). Then \(c\) divides any linear combination of \(a\) and \(b\) by Theorem 4. Hence \(c\mid d\). This proves that any common divisor of \(a\) and \(b\) divides \(d\). Hence \(c\leq d\), and \(d\) is the greatest divisor.

    As a result, we conclude that if \((a,b)=1\) then there exist integers \(m\) and \(n\) such that \(ma+nb=1\).

    Let \(a_1,a_2,...,a_n\) be integers, not all \(0\). The greatest common divisor of these integers is the largest integer that divides all of the integers in the set. The greatest common divisor of \(a_1,a_2,...,a_n\) is denoted by \((a_1,a_2,...,a_n)\).

    The integers \(a_1,a_2,...,a_n\) are said to be mutually relatively prime if \((a_1,a_2,...,a_n)=1\).

    The integers \(3, 6, 7\) are mutually relatively prime since \((3,6,7)=1\) although \((3,6)=3\).

    The integers \(a_1,a_2,...,a_n\) are called pairwise prime if for each \(i\neq j\), we have \((a_i,a_j)=1\).

    The integers \(3,14,25\) are pairwise relatively prime. Notice also that these integers are mutually relatively prime.

    Notice that if \(a_1,a_2,...,a_n\) are pairwise relatively prime then they are mutually relatively prime.


    Exercises

    1. Find the greatest common divisor of 15 and 35.

    2. Find the greatest common divisor of 100 and 104.

    3. Find the greatest common divisor of -30 and 95.

    4. Let \(m\) be a positive integer. Find the greatest common divisor of \(m\) and \(m+1\).

    5. Let \(m\) be a positive integer, find the greatest common divisor of \(m\) and \(m+2\).

    6. Show that if \(m\) and \(n\) are integers such that \((m,n)=1\), then (m+n,m-n)=1 or 2.

    7. Show that if \(m\) is a positive integer, then \(3m+2\) and \(5m+3\) are relatively prime.

    8. Show that if \(a\) and \(b\) are relatively prime integers, then \((a+2b,2a+b)=1\)or \(3\).

    9. Show that if \(a_1,a_2,...,a_n\) are integers that are not all 0 and \(c\) is a positive integer, then \((ca_1,ca_2,...,ca_n)=c(a_1,a_2,...a_n).\)

    Contributors

    • Dr. Wissam Raji, Ph.D., of the American University in Beirut. His work was selected by the Saylor Foundation’s Open Textbook Challenge for public release under a Creative Commons Attribution (CC BY) license.