Greatest common divisors (I) [01DN]
- October 13, 2026
- Marcelo Fiore, Jon Sterling
Definition The set of divisors [01DO]
- October 13, 2026
- Marcelo Fiore, Jon Sterling
Given a natural number n, its set of divisors \mathsf {D}{\mathopen {}\left (n\right )\mathclose {}}\subseteq \mathbb {N} is defined by subset comprehension as follows:
\mathsf {D}{\mathopen {}\left (n\right )\mathclose {}} \coloneqq {\mathopen {}\left \{d:\mathbb {N}\,\middle \vert \,{\mathopen {}\left (d\mid n\right )\mathclose {}}\right \}\mathclose {}}Example Examples of sets of divisors [01DP]
- October 13, 2026
- Marcelo Fiore, Jon Sterling
- \mathsf {D}{\mathopen {}\left (0\right )\mathclose {}} = \mathbb {N}
- \mathsf {D}{\mathopen {}\left (12\right )\mathclose {}} = {\mathopen {}\left \{1,2,3,4,6,12\right \}\mathclose {}}
Sets of divisors are not easy to compute, but the computation of the greatest divisor of n is straightforward: it is n itself!
Lemma Natural numbers represent their divisor sets [01E6]
- October 19, 2026
- Jon Sterling
Any two natural numbers with the same set of divisors are equal.
Proof.
- October 19, 2026
- Jon Sterling
Let a,b be two positive natural numbers such that \mathsf {D}{\mathopen {}\left (a\right )\mathclose {}} and \mathsf {D}{\mathopen {}\left (b\right )\mathclose {}} are equal subsets of \mathbb {N}. Each subset is non-empty, as every natural is divisible by 1, so they each have a greatest element in the standard order of the natural numbers; the maximal element of \mathsf {D}{\mathopen {}\left (n\right )\mathclose {}} is simply n. So we have
a = \max \mathsf {D}{\mathopen {}\left (a\right )\mathclose {}} = \max \mathsf {D}{\mathopen {}\left (b\right )\mathclose {}} = b\text {.}The other case to consider is when either a and b is zero. If a is zero, then \mathsf {D}{\mathopen {}\left (a\right )\mathclose {}}=\mathbb {N} and hence \mathsf {D}{\mathopen {}\left (b\right )\mathclose {}}=\mathbb {N}; we conclude b=0 because no non-zero natural number has an infinite divisor set.
Definition Common divisors [01DQ]
- October 13, 2026
- Marcelo Fiore, Jon Sterling
For a pair of natural numbers m,n:\mathbb {N}, the set \mathsf {CD}{\mathopen {}\left (m,n\right )\mathclose {}}\subseteq \mathbb {N} of common divisors of m and n is defined by subset comprehension as follows:
\mathsf {CD}{\mathopen {}\left (m,n\right )\mathclose {}} \coloneqq {\mathopen {}\left \{d: \mathbb {N}\,\middle \vert \, {\mathopen {}\left (d\mid m\right )\mathclose {}} \land {\mathopen {}\left (d\mid n\right )\mathclose {}} \right \}\mathclose {}}Example [01DR]
- October 13, 2026
- Jon Sterling
Because \mathsf {CD}{\mathopen {}\left (n,n\right )\mathclose {}}=\mathsf {D}{\mathopen {}\left (n\right )\mathclose {}}, calculating common divisors is in general no easier than calculating divisors. It is interesting, however, to consider computing the greatest common divisor.
Definition Greatest common divisor [01E3]
- October 13, 2026
- Marcelo Fiore, Jon Sterling
The greatest common divisor of two natural numbers m,n:\mathbb {N} is defined to be the unique common divisor k\in \mathsf {CD}{\mathopen {}\left (m,n\right )\mathclose {}} satisfying following universal property: every common divisor of m and n divides k.
We will write \gcd {\mathopen {}\left (m,n\right )\mathclose {}} for the greatest common divisor of m and n. Summarising:
\gcd {\mathopen {}\left (m,n\right )\mathclose {}}\in \mathsf {CD}{\mathopen {}\left (m,n\right )\mathclose {}} \qquad \forall d: \mathsf {CD}{\mathopen {}\left (m,n\right )\mathclose {}}\mathpunct {.} d\mid \gcd {\mathopen {}\left (m,n\right )\mathclose {}}Remark Understanding the definition of greatest common divisors [01E4]
- October 13, 2026
- Jon Sterling
You might have expected that the greatest common divisor of m and n would simply be defined to be the greatest natural number that divides both m and n. When m and n are not both zero, that definition is equivalent—but seeing that this is the case is actually difficult. In practice, the definition we have given is the most useful one for mathematics.
One way to understand the use of the word “greatest” in the name is that it refers to the greatest element of the set of common divisors in the divisibility preorder rather than in the usual \leq -order of the naturals—but we have not learned about preorders yet, so we will leave that alone.
Proposition [01DS]
- October 13, 2026
- Marcelo Fiore, Jon Sterling
For all natural numbers l,m,n:\mathbb {N}, we have:
- \mathsf {CD}{\mathopen {}\left (m,n\right )\mathclose {}} = \mathsf {CD}{\mathopen {}\left (n,m\right )\mathclose {}}
- \mathsf {CD}{\mathopen {}\left (l\cdot n,n\right )\mathclose {}} = \mathsf {D}{\mathopen {}\left (n\right )\mathclose {}}
Proof.
- October 13, 2026
- Marcelo Fiore, Jon Sterling
The first statement is immediate by unfolding definitions. For the second statement, we consider that every divisor of n is a divisor of l\cdot n, so the elements in common would be just the divisors of n.
Corollary [01DT]
- October 13, 2026
- Marcelo Fiore, Jon Sterling
For a natural number l, the following hold:
- \mathsf {CD}{\mathopen {}\left (l,l\right )\mathclose {}} = \mathsf {CD}{\mathopen {}\left (l,0\right )\mathclose {}} = \mathsf {D}{\mathopen {}\left (l\right )\mathclose {}}
- \mathsf {CD}{\mathopen {}\left (1,l\right )\mathclose {}} = {\mathopen {}\left \{1\right \}\mathclose {}}
Proof.
- October 13, 2026
- Marcelo Fiore, Jon Sterling
It is immediate that \mathsf {CD}{\mathopen {}\left (l,l\right )\mathclose {}} = \mathsf {D}{\mathopen {}\left (l\right )\mathclose {}} by inspecting definitions. To see that \mathsf {CD}{\mathopen {}\left (l,0\right )\mathclose {}} = \mathsf {D}{\mathopen {}\left (l\right )\mathclose {}}, we note that every divisor of l divides 0, so the elements in common are precisely the divisors of l.
For the second statement, the only divisor of 1 is 1 itself, which is a divisor of l. So there is exactly one element in common, namely 1.
Lemma Key lemma on common divisors [01DU]
- October 13, 2026
- Marcelo Fiore, Jon Sterling
Let m and m' be natural numbers and let n be a positive integer such that m\equiv m'\mod n. Then \mathsf {CD}{\mathopen {}\left (m,n\right )\mathclose {}} = \mathsf {CD}{\mathopen {}\left (m',n\right )\mathclose {}}\text {.}
Proof.
- October 13, 2026
- Marcelo Fiore, Jon Sterling
By the principle of subset extensionality and the definition of common divisors, it suffices to show that for all d:\mathbb {Z}^+ we have (d\mid m \land d\mid n)\Longleftrightarrow (d\mid m'\land d\mid n) \text {.}
In the forward direction, we assume that d divides both m and n, and we need to show that d divides m'. We may therefore assume a,b:\mathbb {Z} such that a\cdot d = m, b\cdot d = n\text {.} By our congruence assumption, we have n\mid m-m' and hence we may further assume some c:\mathbb {Z} such that cn=m-m' and therefore m = cn+m'\text {.}
Calculating with our assumptions, we have \begin {aligned} a\cdot d &= m \\ &= c\cdot n + m' \\ &= c\cdot b\cdot d + m'\text {,} \end {aligned} and so \begin {aligned} m' &= a\cdot d - c\cdot b \cdot d \\ &= d\cdot (a - c\cdot b)\text {.} \end {aligned}
Therefore we have d\mid m'.
The backwards direction is analogous to the above.
Corollary [01DV]
- October 13, 2026
- Marcelo Fiore, Jon Sterling
- For all natural numbers m and positive integers n, \mathsf {CD}{\mathopen {}\left (m,n\right )\mathclose {}} = \mathsf {CD}{\mathopen {}\left (\operatorname {rem}{\mathopen {}\left (m,n\right )\mathclose {}},n\right )\mathclose {}}\text {.}
- For all natural numbers m and n, \mathsf {CD}{\mathopen {}\left (m,n\right )\mathclose {}} = \mathsf {CD}{\mathopen {}\left (q - p,p\right )\mathclose {}} where p=\min {\mathopen {}\left (m,n\right )\mathclose {}} and q = \max {\mathopen {}\left (m,n\right )\mathclose {}}.
Proof.
- October 13, 2026
- Marcelo Fiore, Jon Sterling
For the first statement, we recall from Corollary [01CY] that \operatorname {rem}{\mathopen {}\left (m,n\right )\mathclose {}}\equiv m \mod n, so the claim follows by the key lemma.
For the second statement, we assume without loss of generality that n\leq m so that we must prove \mathsf {CD}{\mathopen {}\left (m,n\right )\mathclose {}} = \mathsf {CD}{\mathopen {}\left (m-n, n\right )\mathclose {}}. We note that m-n\equiv m \mod n always, so the claim follows again by the key lemma.
Lemma Characterisation of common divisors [01DW]
- October 13, 2026
- Marcelo Fiore, Jon Sterling
For all positive integers m and n, we have \mathsf {CD}{\mathopen {}\left (m,n\right )\mathclose {}} = \begin {cases} \mathsf {D}{\mathopen {}\left (n\right )\mathclose {}} &\text {if } n\mid m \\ \mathsf {CD}{\mathopen {}\left (n,\operatorname {rem}{\mathopen {}\left (m,n\right )\mathclose {}}\right )\mathclose {}} &\text {otherwise} \end {cases}
Proof.
- October 13, 2026
- Marcelo Fiore, Jon Sterling
The case where n\mid m is the second part of Proposition [01DS]. The other case is Corollary [01DV].
Idea Recursive calculation of greatest common divisors [01DX]
- October 13, 2026
- Marcelo Fiore, Jon Sterling
Although it is not easy to calculate the set of all common divisors of two positive integers m,n, it will turn out to be easy to calculate the greatest common divisor \gcd {\mathopen {}\left (m,n\right )\mathclose {}}, and our characterisation of common divisors gives us an idea why:
- If n\mid m, then we know that \mathsf {CD}{\mathopen {}\left (m,n\right )\mathclose {}} = \mathsf {D}{\mathopen {}\left (n\right )\mathclose {}} and hence \gcd {\mathopen {}\left (m,n\right )\mathclose {}} = n.
- Otherwise, we know that \mathsf {CD}{\mathopen {}\left (m,n\right )\mathclose {}} = \mathsf {CD}{\mathopen {}\left (n,\operatorname {rem}{\mathopen {}\left (m,n\right )\mathclose {}}\right )\mathclose {}}, so \gcd {\mathopen {}\left (m,n\right )\mathclose {}} = \gcd {\mathopen {}\left (n,\operatorname {rem}{\mathopen {}\left (m,n\right )\mathclose {}}\right )\mathclose {}}.
In summary, we have:
\gcd {\mathopen {}\left (m,n\right )\mathclose {}} = \begin {cases} n &\text {if } n\mid m \\ \gcd {\mathopen {}\left (n,\operatorname {rem}{\mathopen {}\left (m,n\right )\mathclose {}}\right )\mathclose {}} & \text {otherwise} \end {cases}The above is circular and so it isn’t automatically a valid definition; but it is suggestive of an algorithm…
We will come back to this in the next lecture.