Key idea of this section
For a, b ∈ ℤ not both 0, the set {ax + by : x, y ∈ ℤ} is exactly dℤ, where d = gcd(a, b).The well-ordering principle
Every argument in this lesson rests on one axiom of the integers: every non-empty set of natural numbers has a least element. This is equivalent to the principle of mathematical induction, and it is the source of every existence statement below.
Theorem 1.1 (Division algorithm). Let a ∈ ℤ and b ∈ ℕ. There are unique integers q and r with a = bq + r and 0 ≤ r < b.
Proof. Existence: the set S = {a − bk : k ∈ ℤ, a − bk ≥ 0} is non-empty (take k = −|a|, since then a − bk = a + b|a| ≥ a + |a| ≥ 0). Let r = a − bq be its least element. Then r ≥ 0, and if r ≥ b we would have r − b = a − b(q + 1) ∈ S, smaller than r, a contradiction. Uniqueness: if bq + r = bq' + r' with 0 ≤ r, r' < b, then b | r − r' and |r − r'| < b, so r = r' and then q = q'. ∎
Greatest common divisors
For integers a, b not both zero, a common divisor is an integer d with d | a and d | b; the greatest such d is gcd(a, b). It exists because the common divisors are bounded by max(|a|, |b|) and include 1. We say a and b are coprime (relatively prime) if gcd(a, b) = 1.
Theorem 1.2 (Bézout's identity). Let a, b ∈ ℤ, not both 0, and let I = {ax + by : x, y ∈ ℤ}. Then I = dℤ where d = gcd(a, b). In particular there exist integers x, y with ax + by = gcd(a, b).
Proof. I contains positive elements (a² + b² > 0 is one). Let d be the least positive element of I, say d = ax₀ + by₀. Divide a by d: a = dq + r with 0 ≤ r < d. Then r = a − dq = a(1 − qx₀) + b(−qy₀) ∈ I, and minimality of d forces r = 0. So d | a, and similarly d | b. Conversely any common divisor c of a and b divides ax₀ + by₀ = d, so c ≤ |c| ≤ d. Hence d = gcd(a, b). Finally I is closed under addition and under multiplication by integers, so dℤ ⊆ I, and every element ax + by of I is divisible by d, so I ⊆ dℤ. ∎
The structural content of Theorem 1.2 is that ℤ is a principal ideal domain: the ideal (a, b) generated by a and b is principal, generated by gcd(a, b). Two corollaries are used constantly.
Corollary 1.3. A common divisor of a and b divides gcd(a, b); and gcd(a, b) = 1 if and only if ax + by = 1 has an integer solution.
Corollary 1.4 (Generalised Euclid's lemma). If a | bc and gcd(a, b) = 1, then a | c.
Proof. Write ax + by = 1. Multiply by c: acx + bcy = c. Both terms on the left are divisible by a, so a | c. ∎
The Euclidean algorithm
Bézout's theorem is an existence statement; the Euclidean algorithm makes it effective. The key observation is that gcd(a, b) = gcd(b, r) whenever a = bq + r, because the pairs (a, b) and (b, r) have exactly the same common divisors. Repeating the division algorithm produces a strictly decreasing sequence of non-negative remainders, which must reach 0; the last non-zero remainder is the gcd.
Worked example: gcd(1071, 462).
1071 = 2 · 462 + 147 462 = 3 · 147 + 21 147 = 7 · 21 + 0
So gcd(1071, 462) = 21. Running the equations backwards (back-substitution) expresses 21 as a combination:
21 = 462 − 3 · 147 = 462 − 3 · (1071 − 2 · 462) = 7 · 462 − 3 · 1071
Check: 7 · 462 = 3234 and 3 · 1071 = 3213, and 3234 − 3213 = 21.
The extended Euclidean algorithm carries the coefficients forward instead of backward: maintain triples (rᵢ, sᵢ, tᵢ) with rᵢ = a sᵢ + b tᵢ, starting from (a, 1, 0) and (b, 0, 1), and set (rᵢ₊₁, sᵢ₊₁, tᵢ₊₁) = (rᵢ₋₁, sᵢ₋₁, tᵢ₋₁) − qᵢ (rᵢ, sᵢ, tᵢ). This is how computers find modular inverses.
Theorem 1.5 (Lamé, 1844). If the Euclidean algorithm applied to a > b > 0 takes n division steps, then b ≥ Fₙ₊₁, where F₁ = F₂ = 1, Fₖ₊₁ = Fₖ + Fₖ₋₁ are the Fibonacci numbers. Consequently the number of steps is O(log b).
Proof sketch. Let the remainders be r₀ = a, r₁ = b, r₂, …, rₙ > rₙ₊₁ = 0, where step k is rₖ₋₁ = qₖ rₖ + rₖ₊₁, so the last non-zero remainder is rₙ. Then rₙ ≥ 1 = F₂ and rₙ₋₁ ≥ 2 = F₃ (since rₙ₋₁ > rₙ ≥ 1), and each step gives rₖ₋₁ ≥ rₖ + rₖ₊₁. By downward induction rₖ ≥ Fₙ₊₂₋ₖ, so b = r₁ ≥ Fₙ₊₁. Since Fₖ ≥ φk−2 with φ = (1 + √5)/2, the bound n = O(log b) follows. The worst case is consecutive Fibonacci numbers, where every quotient is 1. ∎
Linear Diophantine equations
Theorem 1.6. The equation ax + by = c (a, b not both 0) has an integer solution if and only if d = gcd(a, b) divides c. If (x₀, y₀) is one solution, all solutions are
x = x₀ + (b/d) t, y = y₀ − (a/d) t, t ∈ ℤ.
Proof. Solvability is Theorem 1.2. If (x, y) is another solution then a(x − x₀) = −b(y − y₀); dividing by d gives (a/d)(x − x₀) = −(b/d)(y − y₀), and since gcd(a/d, b/d) = 1, Corollary 1.4 shows (b/d) | (x − x₀). Writing x − x₀ = (b/d)t gives the stated form, and every such pair is a solution. ∎
Least common multiples
The least common multiple [a, b] of non-zero a, b is the least positive common multiple. Every common multiple is a multiple of [a, b] (divide and use minimality), and for positive a, b one has gcd(a, b) · lcm(a, b) = ab. The cleanest proof uses the prime factorisations of Lesson 2: the exponent of p in the gcd is min(vₚ(a), vₚ(b)), in the lcm it is max(vₚ(a), vₚ(b)), and min + max = sum.
Exercise
- (a)Use the Euclidean algorithm to find gcd(252, 198), and find integers x, y with 252x + 198y = gcd(252, 198).
- (b)Find all integer solutions of 252x + 198y = 90.
- (c)Prove that gcd(n² + 1, n + 1) divides 2 for every integer n.
Show solution
Answers: (a) 252 = 1·198 + 54, 198 = 3·54 + 36, 54 = 1·36 + 18, 36 = 2·18, so the gcd is 18. Back-substituting: 18 = 54 − 36 = 54 − (198 − 3·54) = 4·54 − 198 = 4(252 − 198) − 198 = 4·252 − 5·198; check 1008 − 990 = 18. (b) 90 = 5·18, so (x₀, y₀) = (20, −25) is a solution, and all solutions are x = 20 + 11t, y = −25 − 14t (t ∈ ℤ), since 198/18 = 11 and 252/18 = 14. (c) Any common divisor d divides (n² + 1) − (n − 1)(n + 1) = 2.