Why the Euclidean algorithm finds the greatest common divisor: from subtraction to division
The recursion gcd(a,b) = gcd(b, a mod b) hides an invariant: the set of common divisors never changes. Starting from a naive subtraction-based method and upgrading to division, we derive Bezout's identity, the extended Euclidean algorithm, and modular inverses.
The Euclidean algorithm, recorded in Euclid's Elements around 300 BCE, is one of the oldest algorithms known to humanity. Yet textbooks often present it as a bare recursion – – without explaining why this operation reliably produces the greatest common divisor.
1 The definition of the greatest common divisor
2 The naive approach: repeated subtraction
The simplest way to compute the greatest common divisor is by repeated subtraction.
This method is correct but slow. When and are far apart, it can require an enormous number of steps ( would need subtractions).
3 The upgrade to division: why the algorithm is fast
Instead of subtracting one copy of at a time, we subtract as many copies as possible in a single step – that is, we divide.
4 Bézout's identity: the GCD as a linear combination
5 The extended Euclidean algorithm
The constructive proof of Béextended Euclidean algorithm.
6 Computing modular inverses
7 Takeaway
The Euclidean algorithm rests on the invariant that the set of common divisors is unchanged at each step.
Upgrading subtraction to division yields an -time algorithm.
Bé
The extended Euclidean algorithm turns this guarantee into an efficient procedure for computing modular inverses.
In the next article, we examine the "atoms" of the integers – the primes – and ask why the Fundamental Theorem of Arithmetic holds, and in what settings it fails.
Mathematics "between the lines" — exploring the intuition textbooks leave out, written in LaTeX on Folio.