Divisibility, GCD, and the Euclidean Algorithm
One-line statement: For integers (not both zero), the greatest common divisor is the largest positive integer dividing both, and the Euclidean Algorithm computes it via repeated division with remainder. Key result in words: can be expressed as an integer linear combination (Bézout's identity), and the Euclidean Algorithm finds it in division steps. Where it applies: number theory, cryptography (RSA, modular inverses), abstract algebra (PIDs, ideals), computer algebra, rational arithmetic. Who/when: Euclid (~300 BCE, Elements Book VII); formalized over millennia into modern number theory.
If divides both and , then divides every integer combination . In particular divides for any integer . Therefore the set of common divisors of equals the set of common divisors of . Choosing replaces with the remainder , which is strictly smaller. Iterating shrinks the numbers until the remainder is — and the last nonzero remainder is the gcd. The gcd is preserved at every step; only the representation gets simpler.
Formal Statement
For integers with , we say divides (equivalently is a divisor of , or is a multiple of ), written , if there exists an integer with:
Derivation hint: this is a definition; is the quotient. Note for every nonzero , since . Basic properties (for nonzero divisors where needed): and imply ; implies for all ; divisibility is transitive (, ); and with forces .
For any integers and with , there exist unique integers (quotient) and (remainder) such that:
Derivation hint: existence by taking so that ; uniqueness by assuming two representations and bounding their difference below .
For integers not both zero, the greatest common divisor is the unique positive integer satisfying:
Derivation hint: the third clause (every common divisor divides ) is stronger than mere maximality in size; it characterizes the gcd up to sign and is the form that generalizes to rings. By convention for , and is undefined (or set to ). Integers are coprime (relatively prime) when .
For integers not both zero, there exist integers such that:
Derivation hint: let be the smallest positive value of ; show and via the division algorithm (a smaller positive remainder would contradict minimality), and that any common divisor divides . Equivalently, is the smallest positive element of the set , and that set is exactly the set of all multiples of — i.e. the ideal in .
For integers with and :
Derivation hint: show the common-divisor sets of and coincide. If and then ; conversely if and then .
Why It Holds / Derivation
We prove the algorithm — assume WLOG — computes the gcd and halts.
Step 1 — Setup. Define , . Repeatedly apply the division algorithm:
Derivation hint: each line is one application of [2] with divisor , producing remainder .
Step 2 — Termination. The remainders form a strictly decreasing sequence of nonnegative integers . A strictly decreasing sequence of nonnegative integers must reach in finitely many steps. Let be the first zero remainder; then is the last nonzero remainder.
Step 3 — Invariance. By [5], each division step preserves the gcd:
Derivation hint: direct application of the Key Reduction Lemma to line [6].
Step 4 — Chaining. Composing [7] from up through :
Derivation hint: telescope the chain of equalities; the final term uses . Hence the algorithm returns .
Complexity. Each two consecutive remainders satisfy (since either already, or forcing and ). Thus the number of steps is . The worst case occurs for consecutive Fibonacci numbers (Lamé's theorem), giving roughly steps where is the golden ratio.
∎Euclid, working at the Library of Alexandria, presented the algorithm now bearing his name in the Elements, Propositions VII.1–VII.2, originally phrased for "magnitudes" via repeated subtraction (anthyphairesis, "reciprocal subtraction"). His version applied both to integers and to commensurable geometric lengths; if the subtraction never terminates, the magnitudes are incommensurable — the same idea that proves irrational. The algorithm is among the oldest still in everyday computational use, and the ideal-theoretic generalization (gcd as ideal generator) flows directly from his proof structure.
Building Intuition
Picture two rulers of integer lengths and laid end-to-end measuring problems. The gcd is the length of the largest "tile" that can pave both rulers exactly with no gap. The Euclidean Algorithm tiles the long ruler with copies of the short one, then re-tiles the leftover strip with copies of it, and so on — the leftover that finally tiles perfectly is the answer. Geometrically: draw an rectangle, repeatedly cut off the largest possible square; the side of the smallest square you can cut equals . Bézout's identity then says: among all combinations you can build with signed copies of the two rulers, the shortest nonzero length you can reach is exactly the gcd — you can never reach anything shorter, and you can reach every multiple of it.
Worked Examples
Given: , .
Steps (each line is ):
Derivation hint: apply [2] each line; last nonzero remainder is the gcd. The last nonzero remainder is .
Check: and , and . ✓
Given: find with , then compute if it exists.
Forward pass:
Derivation hint: standard division chain; gcd is the last nonzero remainder, . So .
Back-substitution (express as a combination):
Derivation hint: substitute each remainder from the bottom of [10] upward, collecting coefficients of the two original numbers.
Modular inverse? Since , has no inverse mod 240 — the congruence is unsolvable. (An inverse exists iff the numbers are coprime.) However, , so is a "half-inverse." For contrast: , and the same method gives since .
Common Misconceptions
"Greatest" means largest in magnitude — and that's the whole definition. Not quite. The defining property [3] is that the gcd is divisible-into by every common divisor, not merely larger than them. These coincide in , but in general rings (e.g. polynomial rings) "largest" has no meaning while the divisibility characterization still works. Also beware: for all , but equals the gcd only for special — Bézout coefficients are not unique (you can add ).
Bézout fails when "gcd" is the largest common divisor in a non-PID. In the ring , the elements and have only units as common divisors (a "gcd" of in the divisibility sense), yet no elements satisfy . The ideal is not principal. The lesson: Bézout's identity is equivalent to being a principal ideal domain, not a free gift of having gcds. Over we are safe because is a PID; the Euclidean Algorithm is precisely what proves this.
Connections
The Euclidean Algorithm is the computational engine behind much of elementary number theory and algebra. Via Bézout's identity it produces modular inverses, the backbone of solving Linear Congruences and the Chinese Remainder Theorem. Bézout's identity also gives the cleanest proof of Euclid's Lemma ( or ), which in turn yields the Fundamental Theorem of Arithmetic. Abstractly, a ring on which a Euclidean Algorithm runs is a Euclidean Domain, which is automatically a Principal Ideal Domain and hence a Unique Factorization Domain — a tower of implications all anchored by repeated division. The same algorithm runs verbatim on the polynomial ring over a field, computing polynomial gcds and underpinning partial fractions and continued fractions.
Real-World Applications
Historical Development
Subtleties & Limits
The Euclidean Algorithm itself is fully resolved, but its surroundings host genuine difficulties. (1) Which rings are Euclidean? It is unknown for many number rings whether a Euclidean function exists; the question "is the ring of integers of norm-Euclidean?" is settled only for finitely many , and the general "Euclidean but not norm-Euclidean" classification involves deep open conjectures (related to Artin's conjecture on primitive roots). (2) Average-case analysis: the average number of steps for random inputs is (Heilbronn, Dixon), but the finest distributional questions connect to dynamical systems and transfer operators (Baladi–Vallée) that remain active research. (3) gcd of polynomials over inexact (floating-point) coefficients is ill-posed — tiny perturbations destroy common factors — motivating ongoing work on "approximate gcd." (4) The relationship between the Euclidean property and being a PID is subtle: every Euclidean domain is a PID, but there exist PIDs (e.g. ) that are not Euclidean for any function — proving non-Euclideanness required new techniques.
See Also
Bézout's Identity · Euclid's Lemma · Continued Fractions · Principal Ideal Domain · Unique Factorization Domain · Modular Arithmetic · Diophantine Equations · Least Common Multiple