Dividing
What it means for one number to divide another, why division with remainder always works and is unique, and how the Euclidean algorithm finds the greatest common divisor, pictured as a rectangle from which squares are cut.
Almost everything on this website turns on dividing: whether the figure falls into several parts, whether a number is prime, where the twin places lie. This chapter lays the foundation. It follows the seventh book of Euclid’s Elements, which around 300 BC summed up the number theory of the Greeks.
Divisors
Definition
For , is called a divisor of , written , if there is a with .
So , because , but . Every number is divided by 1 and by itself, and every number divides zero.
Theorem 1
For all :
- From and it follows that .
- From and it follows that , and for also .
- From and it follows that .
Proof
- If and , then .
- If and , then .
- If with , then , so .
∎
Division with remainder
If a division does not come out evenly, a remainder is left. That this always works in exactly one way is the first truly important theorem of number theory.
Theorem 2
For and there is exactly one pair with
is called the quotient and the remainder.
Proof
Existence. The multiples grow beyond every bound. Let be the largest with and . If , then , against the choice of . So .
Uniqueness. Let also with , and without loss of generality . Then . The right side is smaller than , the left a multiple of , so both are 0. Hence and .
∎
Division with remainder is nothing but counting on a clock with hours. Chapter 5 builds on it, and it is also the core of the figures : whoever keeps moving on along points is calculating with the remainder on division by .
The greatest common divisor
Definition
For , not both 0, is the largest number that divides and .
One could write down all divisors of both numbers and pick the largest common one. Euclid hands down a much faster way, which is probably older still.
Theorem 3
For and , the pairs and have the same common divisors. In particular
Proof
Let with . If divides and , it divides and by Theorem 1 also . Conversely, if divides and , it divides . So the two pairs have the same common divisors and hence the same greatest one.
∎
Applying Theorem 3 again and again, the numbers get smaller at every step, since the remainder is smaller than the divisor. At some point the remainder is 0, and then . This is the Euclidean algorithm, the oldest non-trivial procedure of calculation still in use today. For 21 and 13:
The last divisor, at which the remainder becomes 0, is the gcd: . The two numbers are coprime.
The Greeks thought of line segments. From a rectangle with sides and you cut as many squares as possible, from the rest again, and so on. The side of the last square that fits exactly is the common measure of both sides, the gcd. The procedure is called anthyphairesis, “mutual taking away”, and Euclid describes it in the Elements VII 1 and 2, with line segments, the picture with the rectangle is a modern illustration.
Squares are cut from the rectangle a × b, each colour one step of the algorithm. The smallest square measures both sides exactly, its side is the gcd. The buttons 1 : √2 and 1 : φ show what happens when there is no common measure (see Chapter 9).
The gcd as a sum
One last theorem about the gcd becomes indispensable in the next chapter. For it we also need negative numbers, the integers .
Theorem 4
For there are integers with
Proof
Let be the smallest positive number of the form with . Such numbers exist, for example . Dividing by with remainder, with , gives
again of this form. Since is the smallest positive such number, , so . Likewise . Every common divisor of and divides and by Theorem 1 is at most . Hence .
∎
For 10 and 4, for example, . The theorem bears the name of Étienne Bézout, who proved it for polynomials in 1779. For integers Claude-Gaspard Bachet already knew it in 1624.
Checked by computer: the proof in Lean
division_with_remainder is the existence part of Theorem 2, remainder_unique the uniqueness. In Lean a / b is the quotient and a % b the remainder. common_divisors is Theorem 3 in the form “same common divisors”, and the last line makes Lean run the Euclidean algorithm for 10 and 4. Theorem 4 is already proven in Lean’s library and is used in Chapter 4.
/-! Chapter 3: division with remainder and the greatest common divisor -/
/-- Theorem 2: Division with remainder. For a and b > 0 there are
q and r < b with a = b · q + r. -/
theorem division_with_remainder (a b : Nat) (hb : 0 < b) :
a = b * (a / b) + a % b ∧ a % b < b :=
⟨(Nat.div_add_mod a b).symm, Nat.mod_lt a hb⟩
/-- … and q and r are uniquely determined. -/
theorem remainder_unique (b q r q' r' : Nat)
(hr : r < b) (hr' : r' < b) (h : b * q + r = b * q' + r') :
q = q' ∧ r = r' := by
have h1 : (b * q + r) / b = q := by
rw [Nat.add_comm, Nat.add_mul_div_left _ _ (by omega)]
simp [Nat.div_eq_of_lt hr]
have h2 : (b * q' + r') / b = q' := by
rw [Nat.add_comm, Nat.add_mul_div_left _ _ (by omega)]
simp [Nat.div_eq_of_lt hr']
have hq : q = q' := by rw [← h1, ← h2, h]
subst hq
exact ⟨rfl, by omega⟩
/-- Theorem 3: The common divisors of a and b are exactly
those of b and a mod b. -/
theorem common_divisors (a b d : Nat) :
(d ∣ a ∧ d ∣ b) ↔ (d ∣ b ∧ d ∣ a % b) := by
constructor
· intro ⟨ha, hb⟩
exact ⟨hb, (Nat.dvd_mod_iff hb).mpr ha⟩
· intro ⟨hb, hr⟩
exact ⟨(Nat.dvd_mod_iff hb).mp hr, hb⟩
-- The Euclidean algorithm for 10 and 4:
-- gcd(10, 4) = gcd(4, 2) = gcd(2, 0) = 2
example : Nat.gcd 10 4 = 2 := by decideTry it in the browser at live.lean-lang.org ↗How to read Lean
Where this appears on the website
The gcd decides the shape of every figure (Chapter 6, Numbers as figures). The three relations between a number and a divisor that The key to the tetractys describes are exactly the three cases , and . And the division table colours its fields by these cases (see Simplexes and primes in the division table).
Sources and further reading
Sources
- Euclid, Elements, around 300 BC, book VII, 1 and 2
- Claude-Gaspard Bachet de Méziriac, Problèmes plaisans et délectables, 2nd ed. Lyon 1624
- Étienne Bézout, Théorie générale des équations algébriques, Paris 1779
Further reading
- G. H. Hardy and E. M. Wright, An Introduction to the Theory of Numbers, Oxford 1938, 6th ed. 2008