Lecture 7: modular arithmetic, integer linear combinations, sets, subsets, comprehension, common divisors [01CZ]
- October 8, 2026
- Marcelo Fiore, Jon Sterling
These lecture notes were prepared by Jon Sterling using Marcelo Fiore’s lectures as source material. Any mistakes were introduced by Jon Sterling. Generative AI was not used to write these lecture notes.
Modular arithmetic [01D0]
- October 8, 2026
- Marcelo Fiore, Jon Sterling
In the previous lecture, we considered the modular normal form of an integer 0\leq [k]_m <m, which had the defining property that k \equiv [k]_m\mod m. In this lecture, we will use this idea to create a new number system \mathbb {Z}_m for each modulus m, which is called the integers modulo m.
Definition Modular integers [01D2]
- October 8, 2026
- Marcelo Fiore, Jon Sterling
For a positive integer m, the integers modulo m consist of the set \mathbb {Z}_m \coloneqq {\mathopen {}\left \{0,\ldots ,m-1\right \}\mathclose {}} with the modular +_m and multiplication \cdot _m defined as follows, using the modular normal forms of naturals:
\begin {aligned} k +_m l &= [k + l]_m &&= \operatorname {rem}{\mathopen {}\left (k+l,m\right )\mathclose {}} \\ k\cdot _m l &= [k+l]_m &&= \operatorname {rem}{\mathopen {}\left (k\cdot l, m\right )\mathclose {}} \end {aligned}In other words, for all k,l:\mathbb {Z}_m, k+_m l\quad \text {and}\quad k\cdot _m l are the unique modular integers in \mathbb {Z}_m such that \begin {aligned} k+_m l &\equiv k+ l &\mod m,\\ k\cdot _m l &\equiv k \cdot l &\mod m\text {.} \end {aligned}
Observation Equality of modular integers is congruence [01F0]
- October 28, 2026
- Jon Sterling
For any modular integers i,j:\mathbb {Z}_m, we have i=j if and only if i\equiv j \mod m.
Proof.
- October 28, 2026
- Jon Sterling
Example Integers modulo 2 [01D3]
- October 8, 2026
- Marcelo Fiore, Jon Sterling
The modular-arithmetic structure {\mathopen {}\left (\mathbb {Z}_2,+_2,0,\cdot _2,1\right )\mathclose {}} is that of the booleans with XOR as addition and AND as multiplication.
Proof.
- October 8, 2026
- Marcelo Fiore, Jon Sterling
To verify the claim, rather than explicitly calculating the values of the additive and multiplicative structure, we instead use the universal property of their definitions. In particular, we need only check the following for all x,y\in {\mathopen {}\left \{0,1\right \}\mathclose {}}:
x \oplus y \equiv x + y \mod 2\text {,} \qquad x\land y \equiv x \cdot y \mod 2\text {.}This is easily seen by constructing addition and multiplication tables.
| \oplus | 0 | 1 |
|---|---|---|
| 0 | 0 | 1 |
| 1 | 1 | 0 |
| \land | 0 | 1 |
|---|---|---|
| 0 | 0 | 0 |
| 1 | 0 | 1 |
Example Addition and multiplication in \mathbb {Z}_4 [01D4]
- October 8, 2026
The addition and multiplication tables for the integers modulo 4 are as follows:
| +_4 | 0 | 1 | 2 | 3 |
|---|---|---|---|---|
| 0 | 0 | 1 | 2 | 3 |
| 1 | 1 | 2 | 3 | 0 |
| 2 | 2 | 3 | 0 | 1 |
| 3 | 3 | 0 | 1 | 2 |
| \cdot _4 | 0 | 1 | 2 | 3 |
|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 0 |
| 1 | 0 | 1 | 2 | 3 |
| 2 | 0 | 2 | 0 | 2 |
| 3 | 0 | 3 | 2 | 1 |
Notice how the addition table has a cyclic pattern, while there is no obvious pattern in the multiplication table.
From the addition and multiplication tables, we can readily read tables for additive and multiplicative inverses, where they exist:
| additive inverse | multiplicative inverse | |
|---|---|---|
| 0 | 0 | none |
| 1 | 3 | 1 |
| 2 | 2 | none |
| 3 | 1 | 3 |
Interstingly, we have one non-trivial multiplicative inverse: 3\cdot _4 3 = 1.
Example Addition and multiplication in \mathbb {Z}_5 [01D5]
- October 8, 2026
- Marcelo Fiore, Jon Sterling
The addition and multiplication tables for the integers modulo 5 are as follows:
| +_5 | 0 | 1 | 2 | 3 | 4 |
|---|---|---|---|---|---|
| 0 | 0 | 1 | 2 | 3 | 4 |
| 1 | 1 | 2 | 3 | 4 | 0 |
| 2 | 2 | 3 | 4 | 0 | 1 |
| 3 | 3 | 4 | 0 | 1 | 2 |
| 4 | 4 | 0 | 1 | 2 | 3 |
| \cdot _5 | 0 | 1 | 2 | 3 | 4 |
|---|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 0 | 0 |
| 1 | 0 | 1 | 2 | 3 | 4 |
| 2 | 0 | 2 | 4 | 1 | 3 |
| 3 | 0 | 3 | 1 | 4 | 2 |
| 4 | 0 | 4 | 3 | 2 | 1 |
From the addition and multiplication tables, we can readily read a table of additive and multiplicative inverses:
| additive inverse | multiplicative inverse | |
|---|---|---|
| 0 | 0 | none |
| 1 | 4 | 1 |
| 2 | 3 | 3 |
| 3 | 2 | 2 |
| 4 | 1 | 4 |
Proposition Commutative rings of modular integers [01D6]
- October 12, 2026
- Marcelo Fiore, Jon Sterling
For each positive integer m, the modular arithmetic structure (\mathbb {Z}_m, +_m,0,\cdot _m,1) is a commutative ring.
Proof.
- October 12, 2026
- Marcelo Fiore, Jon Sterling
You may do this as an exercise; the most interest part lies in establishing the associativity laws of addition and multiplication.
Proposition Reciprocals of modular integers [01D7]
- October 12, 2026
- Marcelo Fiore, Jon Sterling
Let m be a positive integer. A modular integer k:\mathbb {Z}_m has a reciprocal if and only if there exist integers i,j such that k\cdot i+m\cdot j = 1.
Proof.
- October 12, 2026
- Marcelo Fiore, Jon Sterling
Let m be a positive integer and fix k:\mathbb {Z}_m.
In the forward direction, we assume that k has a reciprocal in \mathbb {Z}_m, i.e. some \bar {k}:\mathbb {Z}_m such that k\cdot _m \bar {k} \equiv 1\mod m. We must find integers i,j such that k\cdot i + m \cdot j = 1. Choosing i \coloneqq \bar {k}, we have k\cdot i \equiv k\cdot _m i \equiv 1 \mod m and therefore m \mid (k\cdot i - 1) and hence k\cdot i - 1 = m\cdot l for some l. Hence k\cdot i - m\cdot l = 1, so we may choose j\coloneqq -l.
In the backward direction, we suppose that we have i,j such that k\cdot i + m\cdot j = 1. We must find a reciprocal for k; in fact, the modular normal form [i]_m is such a reciprocal:
\begin {aligned} k \cdot _m [i]_m &= [k\cdot i]_m \\ &\equiv k\cdot i &\mod m \\ &= 1 - m\cdot j \\ &\equiv 1 &\mod m \end {aligned}Integer linear combinations I [01D8]
- October 12, 2026
- Marcelo Fiore, Jon Sterling
Definition Integer linear combination [01D9]
- October 12, 2026
- Marcelo Fiore, Jon Sterling
An integer r is said to be an (integer) linear combination of a pair of integers m and n when there are integers s and t, referred to as the coefficients of the linear combination, such that s\cdot m + t\cdot n = r.
You may or may not have already seen the following notation for the sum of the multiplications of m and n by their coefficients:
\begin {bmatrix} s & t \end {bmatrix} \otimes \begin {bmatrix} m \\ n \end {bmatrix} = rThe above is a special case of matrix multiplication, which we will get to in a few lectures. Don‘t worry if you have no idea what matrix multiplication is yet.
Of course, the idea of linear combination makes sense in any monoid.
Proposition Reciprocals of modular integers in terms of linear combination [01DA]
- October 12, 2026
- Marcelo Fiore, Jon Sterling
Let m be a positive integer. A modular integer k:\mathbb {Z}_m has a reciprocal if and only if 1 is an integer linear combination of m and k.
Proof.
- October 12, 2026
- Marcelo Fiore, Jon Sterling
This is nothing more than a reformulation of our characterisation of reciprocals of modular integers.
Sets [01DB]
- October 12, 2026
- Marcelo Fiore, Jon Sterling
Very roughly, sets are simplest of the mathematician’s data structures: although mathematicians concern themselves with more complex structures, like groups and rings and vector spaces, these are all (at the end of the day) defined in terms of sets.
Sets for mathematics, not mathematics for sets! [01DC]
- October 12, 2026
- Jon Sterling
Set theory is a mathematical subfield, just like group theory or finite model theory or geometry. Set theorists study concrete mathematical models of the abstract concept of a set, often embodied in formalisms like Zermelo–Fraenkel Set Theory, and many others. Set theory is an interesting and important field, but it is focused on a certain aspect of the concept of a set that is not the main one for its application in general mathematics, namely the tree structure of the \in -relation.
Sets in general mathematics, the kind of mathematics that you will need to know, behave a little differently from their incarnation in formal set theory. Some of you may know about things like the union and intersection of sets: in formal set theory, you can take the union of any two sets, but in actual mathematics, one never takes the union of two unrelated sets: the union is only a sensible operation to do on sets A and B that arose first as subsets of a common set C. So, if we are viewing \mathbb {N} and \mathbb {Q}^+ as subsets of \mathbb {R}, we can take the union \mathbb {N}\cup \mathbb {Q}^+ but otherwise it would be very unusual to do so.
The formal set theorists aren‘t wrong, but the way they think about sets is different from how sets are used in mathematics. Because this is a course on mathematics and not a course on set theory, we will favour the point of view of mathematics. You will not be penalised for using your pre-existing knowledge of set theory, if you have it: but you can think of this as an opportunity to learn how mathematicians actually work.
A warning: most mathematicians will tell you that they are using a set theory like ZFC. This is more of a catechism than a reality; what they mean is that they generally accept the mathematical consequences of the ZFC model of sets, not that they are actually using ZFC sets. You should do as mathematicians do, not as they say.
Sets, membership, and subsets [01DD]
- October 12, 2026
- Jon Sterling, with contributions from Marcelo Fiore
Primitive sets [01DF]
- October 12, 2026
- Marcelo Fiore, Jon Sterling
Although only implicitly, we have already encountered many sets so far, like the sets of natural numbers \mathbb {N}, the integers \mathbb {Z}, the positive integers, the even integers, the primes, the rationals \mathbb {Q}, the reals \mathbb {R}, the booleans, and even finite initial segments of the naturals \mathbb {Z}_m. It is fine to think of these sets as primitive or built-in to the vernacular of mathematics.
Notation Set membership [01DG]
- October 12, 2026
- Jon Sterling
We have already been writing a\in A to mean that a is an element of the set A. This notation is slightly more subtle than it may seem; sometimes you may see the notation used to introduce or bind an arbitrary element of the set A, as in:
Let a\in A be an element such that…
Other times, we are writing “a\in A” as a mathematical statement, as in:
For an integer x, we have x\in \mathbb {Z}^+ if and only if x is both natural and non-zero.
These two uses are not the same. In the first usage, it is better (but not mandatory) to write a:A, in keeping with our notation for universal quantification. On the other hand, the second usage is only meaningful when we already know that x is the kind of thing that can be an element of a given set: if we are viewing \mathbb {Z}^+ as a subset of the integers, a statement like x\in \mathbb {Z}^+ is only meaningful if we have already introduced x as an integer.
If this feels a little dizzying, don’t worry. You will get the hang of it soon.
Beyond the primitive sets, there are many other ways to build up more complex sets.
We will study several of them in this course. But the first and most important one is the subset.
Definition Subset [01DH]
- October 12, 2026
- Jon Sterling
A subset of a set A is a set whose elements are the elements of A that satisfy some condition. For example, the naturals can be thought of as the subset of the integers whose elements are precisely the non-negative integers.
We write U\subseteq A to mean that U is a subset of A; we may write U\subset A to mean that U is a strict subset of A, i.e. one that does not contain every element of A.
Given x:A and U\subseteq A, we will write x\in U to mean the statement that x satisfies the condition of being an element of U.
Notation Subset comprehension [01DI]
- October 12, 2026
- Marcelo Fiore, Jon Sterling
To actually write down a specific subset of a set A, we use the subset comprehension notation. Given a predicate P(x) ranging over an element x:A, we will write {\mathopen {}\left \{x: A\,\middle \vert \,P(x)\right \}\mathclose {}} to mean the subset of A that consists of all the elements satisfying P.
To give an element of {\mathopen {}\left \{x: A\,\middle \vert \,P(x)\right \}\mathclose {}}, you just have to give an element of A that satisfies P. If you assume an element of {\mathopen {}\left \{x: A\,\middle \vert \,P(x)\right \}\mathclose {}}, is equivalent to assuming an element x:A followed by an additional assumption P(x).
Example Examples of subset comprehension [01DJ]
- October 12, 2026
- Marcelo Fiore, Jon Sterling
- \mathbb {N} = {\mathopen {}\left \{n:\mathbb {Z}\,\middle \vert \,n\geq 0\right \}\mathclose {}}
- \mathbb {N}^+ = {\mathopen {}\left \{n: \mathbb {N}\,\middle \vert \,n \geq 1\right \}\mathclose {}}
- \mathbb {Q} = {\mathopen {}\left \{x:\mathbb {R}\,\middle \vert \,\exists p:\mathbb {Z}\mathpunct {.}\exists q:\mathbb {N}^+\mathpunct {.} x = p/q\right \}\mathclose {}}
- \mathbb {Z}_{\mathrm {googolplex}} = {\mathopen {}\left \{n:\mathbb {N}\,\middle \vert \,n<\mathrm {googolplex}\right \}\mathclose {}}
Being a subset is reflexive and transitive [01DK]
- October 12, 2026
- Jon Sterling
Reflexivity: For any set A, we may think of A as a subset of itself, as a shorthand for the subset comprehension {\mathopen {}\left \{x: A\,\middle \vert \,\mathrm {true}\right \}\mathclose {}}.
Transitivity: Now, suppose we have a subset U\subseteq A and a subset V\subseteq U. We can think of V also as a subset of A, writing V\subseteq A as a shorthand for the subset comprehension {\mathopen {}\left \{x: A\,\middle \vert \,x\in U \land x\in V\right \}\mathclose {}}.
We will not belabour this point in our notation. The point is that you may view a subset of a subset of A as a subset of A without any further a-do.
In mathematics, we do not talk about two unrelated sets being “equal”. If, however, we are thinking of these two sets as being subsets of a third set, then it makes sense to speak of them being equal.
The principle of subset extensionality [01DL]
- October 12, 2026
- Marcelo Fiore, Jon Sterling
Let A and B be two subsets of a set X. Then we say that A and B are equal when they have the same elements. In other words:
A = B \Longleftrightarrow \forall x:X\mathpunct {.} x\in A \Longleftrightarrow x\in BExample Examples of equal subsets [01DM]
- October 12, 2026
- Marcelo Fiore, Jon Sterling
- As subsets of \mathbb {N}, {\mathopen {}\left \{x:\mathbb {N}\,\middle \vert \,2\mid x \land \mathsf {isPrime}(x)\right \}\mathclose {}} and {\mathopen {}\left \{2\right \}\mathclose {}} are equal.
- For any positive integer m, {\mathopen {}\left \{x:\mathbb {Z}\,\middle \vert \,m\mid x\right \}\mathclose {}} and {\mathopen {}\left \{x:\mathbb {Z}\,\middle \vert \,x\equiv 0 \mod m\right \}\mathclose {}} are equal as subsets of \mathbb {Z}.
- As subsets of \mathbb {N}, {\mathopen {}\left \{d:\mathbb {N}\,\middle \vert \,d\mid 0\right \}\mathclose {}} and \mathbb {N} itself are equal.
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.