The Greatest Common Divisor
Suppose two gears have and teeth. What is the largest "unit size" that divides both counts evenly? This should allow the gears' motion to be described in synchronized whole cycles. This is the concrete question behind the greatest common divisor. It is one of the oldest and most load-bearing ideas in number theory. It quietly underlies fraction simplification, modular arithmetic, cryptographic key generation, and the structure of the integers themselves. The idea matters because divisibility alone is a coarse relation. Many numbers divide a given pair. We need a way to isolate the best common measure. The gcd packages all common divisors of two integers into a single number. This number captures exactly their shared arithmetic structure. Once this number is understood correctly, deeper facts follow. It can be written as an integer combination of the two numbers. It is computable efficiently. It governs solvability of linear Diophantine equations. The big picture is that is not just an operation. It is a universal object: the largest element, in the divisibility ordering, that lies below both inputs. This lattice-theoretic viewpoint explains why gcd behaves so well algebraically. It interacts cleanly with multiplication and distributes over products. It also gives rise to the notion of coprimality, the condition of having no shared structure at all. This article gives the precise definition of . It establishes its basic existence and uniqueness. It proves the core elementary properties: linearity under common factors, behavior under scaling, coprimality criteria. It also sets up the language needed for the Euclidean Algorithm and Bezout's Identity. These show how to compute and represent the gcd explicitly.
- The gcd of integers (not both zero) is the largest integer dividing both.
- Equivalently, it is characterized by a divisibility-universal property: every common divisor divides it.
- exists and is unique for any pair not both zero, by well-ordering.
- and are coprime (or relatively prime) when .
- Key identities: for any integer .
- Key idea: the gcd is the unique nonnegative generator of the set of all integer combinations , a fact whose proof foreshadows Bezout's identity.
Where this lives today
The gcd is the load-bearing gear of elementary number theory: it is the precise tool that reduces fractions to lowest terms ( with ), and it is the exact solvability criterion for the linear Diophantine equation (solvable in integers iff , a direct consequence of Bezout's identity above). In modular arithmetic, is precisely the condition for to be invertible modulo , which is the backbone of the RSA cryptosystem: key generation requires choosing an encryption exponent coprime to , and decryption relies on computing its modular inverse via the extended Euclidean algorithm. In computer science, the gcd computation is a textbook example of an algorithm with provably efficient (logarithmic) running time, underlying implementations in every major arithmetic library. In algebra, the notion generalizes to principal ideal domains, where gcd is defined via ideal containment exactly mirroring the universal property given here; this generalization is essential in ring theory and algebraic number theory. In combinatorics and dynamical systems, of periods governs the structure of orbits and lattice points, e.g. determining when a line through the origin with rational slope (in lowest terms) first returns to a lattice point.
Ask the tutor: How does the Euclidean Algorithm turn the reduction property into a concrete finite procedure, and how do we extract the Bezout coefficients from it?
Let , not both zero. An integer is a common divisor of and if and . The greatest common divisor of and , written , is the unique integer satisfying: 1. ; 2. and (i.e., is a common divisor); 3. for every common divisor of and , . Condition (3) is the universal property: is not merely numerically the largest common divisor, it is divisible by every common divisor. We will show (Theorem below) that such a exists and is unique, and that it coincides with the largest common divisor in the usual numerical sense. Two integers are called coprime (or relatively prime) if . By convention, is left undefined (every integer divides , so there is no largest common divisor of and ), and for .
Intuition
Think of divisibility as an ordering on the positive integers: means . Under this order, not every pair of numbers is comparable — and neither divide each other — but every pair still has a well-defined meet, a greatest lower bound in the divisibility order. That meet is exactly . The gcd is the divisibility-lattice analogue of "the larger of two numbers" under the usual order . A second, equally important picture: fix and , and look at the set of all integer combinations
This set is closed under addition and under multiplication by any integer, and it contains both and (take or ). It turns out consists precisely of all multiples of a single positive integer — and that integer is . This is the seed of Bezout's Identity, which asserts for suitable integers ; we prove the existence half of this fact below as part of establishing gcd's universal property.
Let , not both zero. Then:
(a) Existence and Bezout representation. There exists a positive integer such that
and this satisfies , , and for every common divisor of we have .
(b) Uniqueness. There is exactly one positive integer satisfying properties (1)–(3) of the definition above; hence .
(c) Coincidence with the numerical maximum. equals the largest element of the (finite, nonempty) set of common divisors of and under the usual ordering on integers.
We use the Well-Ordering Principle (every nonempty set of positive integers has a least element) together with the Division Algorithm.
Step 1: The set of positive integer combinations is nonempty. Let
Since are not both zero, at least one of is a positive integer, and each of these is of the form (e.g. , , similarly for ). Hence .
Step 2: Existence of a minimal element. By the Well-Ordering Principle, has a least element . Write for some ; note .
Step 3: divides . Apply the Division Algorithm to divide by : there exist unique with
Then
so is an integer combination of and . If , then and , contradicting minimality of in . Hence , so , i.e. .
Step 4: divides . By the identical argument with the roles of swapped, . So is a positive common divisor of and , and for some integers .
Step 5: Universal property. Let be any common divisor of and : and . By the basic linearity property of divisibility (if and then divides any integer combination ), we get
This proves the universal property (3), completing (a).
Step 6: Uniqueness. Suppose and both satisfy properties (1)–(3) of the definition. By property (3) applied to as a "common divisor" candidate for the universal property of — precisely, since is itself a common divisor of and satisfies the universal property — we get . Symmetrically, . Two positive integers that divide each other must be equal: if and , write and for positive integers ; then , so , forcing since both are positive integers. Hence . This proves (b).
Step 7: Coincidence with the numerical maximum. The set of common divisors of is nonempty (it contains ) and finite: since are not both zero, some one of them, say , has only finitely many divisors (namely divisors of , at most many, since any divisor of satisfies ), and every common divisor of divides . So has a maximum element under . We show . Since (Step 3–4), . Conversely, is a common divisor, so by the universal property (Step 5), ; since and (as ), this gives . Hence , proving (c).
∎For not both zero, there exist integers such that
(This is exactly established in Step 2–4 of the proof above; the full computational machinery for finding is the subject of <a class="wiki-link" href="/wiki/math-numthy-bezout-identity" data-track="wiki_article.body.wiki_link">Bezout's Identity</a> proper, via the extended <span class="wiki-link-missing">Euclidean Algorithm</span>.)
Let with the relevant pairs not both zero. Then: 1. Symmetry: . 2. Sign invariance: . 3. Reduction: for any integer , . In particular when . 4. Scaling: for , . 5. Coprimality criterion: if and only if there exist integers with . 6. Coprime cancellation: if and , then .
(1) Immediate: the defining conditions "" and "every common divisor divides " are symmetric in .
(2) The divisors of and of are identical (since for all ), so the set of common divisors of equals that of ; hence the two gcds, each characterized as the unique positive integer divisible by all elements of this common set and dividing... (more precisely, satisfying the same universal property with respect to the same set of common divisors) — must coincide, by the uniqueness in the Theorem.
(3) Let be the set of common divisors of and the set of common divisors of . We claim . If , then and , so (divisibility is linear: a common divisor of two numbers divides any integer combination of them), hence . Conversely if , then and , so , hence . Since , the two gcds — each the unique positive integer that is a common divisor from this set and divisible by every element of it — coincide by uniqueness (Theorem, part (b)).
(4) Let . We show satisfies the defining properties for . First, . Since , write ; then , so ; similarly . Now let be any common divisor of . By Bezout (Corollary above), write ; then
so since and , linearity gives . Thus satisfies all three defining properties, and by uniqueness .
(5) () If , the Bezout Corollary gives integers with . () Suppose for some integers . Let (exists since not both are zero, as forces at least one nonzero). Since and , linearity gives . As is a positive divisor of , .
(6) Since , by (5) choose integers with . Multiply by :
Now trivially, and because by hypothesis. Hence divides the sum .
∎Worked examples
Example 1: Computing via the reduction lemma, and verifying the universal property directly. We use Lemma property (3) repeatedly (this is precisely the mechanism behind the Euclidean Algorithm, though we verify it by hand here rather than invoking that theorem):
So . Direct check via the definition. Factor: , and . Common divisors must be products of shared prime powers: copies of and copy of (the prime does not divide ). So the largest common divisor is , matching the reduction computation. We can also verify the universal property directly: divisors of are ; one checks each of these does divide both and (e.g. since , and since ), while any other common divisor of — say from the factorizations above, the only common divisors are exactly since these are the only products with — so indeed the maximum is divisible by all smaller common divisors, consistent with the Theorem.
Example 2: Finding an explicit Bezout pair for and applying coprime cancellation. First compute the gcd:
So : they are coprime. Back-substituting (this is the extended algorithm, previewed here):
Check: , , and . So
confirming via Lemma property (5), with explicit . Now apply the coprime cancellation property (6): suppose we are told for some integer . Since , property (6) with gives . Concretely, take for any integer ; then , and indeed while also , consistent with (and not contradicting) the claim — the content of (6) is that no other can satisfy , which one can also verify from the Bezout identity directly: multiplying by gives , and since divides both terms on the left (the first obviously, the second because by hypothesis), .
Drop the hypothesis that are not both zero, and consider . Every integer satisfies (since ), so the set of common divisors of and is all of , which has no largest element and no positive element divisible by every other positive integer. Concretely: is there a positive integer such that every integer divides ? No — for any candidate , the integer is also a common divisor of , yet . So the universal property (3) in the definition is unsatisfiable, and genuinely does not exist; it is not merely a convention we could fix by picking "the largest," because there is no largest. This shows the hypothesis "not both zero" in the Theorem is essential, not a technicality: the Well-Ordering argument in Step 1 of the proof used it exactly to guarantee .
Scope, edge cases & common traps
| Situation | What happens | Correct statement |
|---|---|---|
| Every integer divides ; the common divisors of are exactly the divisors of , whose max is . | ||
| Undefined | No largest common divisor exists (Counterexample above). | |
| negative | Sign invariance (Lemma, part 2); gcd is always taken . | |
| but neither nor is | Perfectly normal | E.g. ; coprimality is about shared factors, not about either number being a unit. |
| Confusing "" with " prime" | Common student error | Coprimality is a property of the pair; and are both composite yet coprime. |
The mathematician behind it
Origins · 1 minEuclid of Alexandria and how this was discovered
Euclid compiled and systematized geometry and number theory in his Elements, a work whose axiomatic method shaped all of subsequent mathematics. Book VII of the Elements contains what is now called the Euclidean Algorithm for finding the greatest common measure (μέγιστον κοινὸν μέτρον) of two magnitudes — the ancestor of the modern gcd, originally phrased geometrically via repeated subtraction of line segments rather than via the division algorithm's quotient-remainder form used in modern textbooks.
Why is undefined instead of being defined as ?
Some conventions do set by declaring it to be the largest element in the divisibility partial order (since every integer divides , and is "above" everything divisibility-wise, so it is the top element, not the largest numerically). This article uses the stricter classical convention requiring to be an actual maximum under , which fails for because there is no numerically largest common divisor (every positive integer is a common divisor). Both conventions are used in the literature; what is essential is that the "not both zero" hypothesis is needed for the numerical maximum characterization to make sense, as the Counterexample block demonstrates directly.
Is always positive?
Yes, by definition, whenever are not both zero. Even if and are both negative, is defined to be a positive integer, because divisibility is insensitive to sign (), and the definition explicitly requires . For instance , not . This convention keeps gcd well-defined as a single canonical representative rather than a pair .
How is gcd related to least common multiple?
For positive integers , the identity holds. This can be proven directly from prime factorizations: if and , then and , and since for every prime, multiplying gives . This relation lets one compute lcm quickly once gcd is known via the Euclidean Algorithm, without factoring.
Does gcd extend to more than two integers?
Yes. For integers not all zero, is defined as the unique positive integer dividing all of them such that every common divisor of all of them divides it; it can be computed iteratively as , using the associativity-like property , which follows from the same universal-property argument applied twice. All the theorems in this article extend to this setting essentially unchanged, replacing pairs of common divisors with -tuples.
What is the difference between "coprime" and "pairwise coprime" for three or more integers?
Integers are (jointly) coprime if , meaning no integer greater than divides all three simultaneously. They are pairwise coprime if , a strictly stronger condition. For example, satisfy (jointly coprime) but are not pairwise coprime, since . This distinction matters in applications like the Chinese Remainder Theorem, which requires the stronger pairwise condition.
Can gcd be computed without factoring into primes?
Yes, and this is one of the most important practical facts in the subject: the reduction property established in the Lemma is exactly what powers the Euclidean Algorithm, which computes using only repeated division, with no factorization required. This is dramatically faster than factoring for large numbers, which is why gcd computation (not factoring) is the practical tool used in cryptographic key generation.
Why does the proof avoid just saying "let be the largest common divisor" from the start?
Because existence of a largest common divisor is not obvious a priori — it requires knowing the set of common divisors is finite and nonempty, which itself uses that are not both zero. The proof instead builds from the Well-Ordering Principle applied to integer combinations, which simultaneously delivers the Bezout representation used to prove the universal property. Constructing this way, rather than assuming it as "the biggest one," is what makes the proof non-circular and provides the Bezout identity as a free byproduct.