Overview

The greatest common divisor measures the common divisibility of two integers. It also answers an apparently different question: which integers can be made by adding integer multiples of the two inputs? This second interpretation makes the gcd useful for linear Diophantine equations, modular inverses, and calculations with ideals.

Prerequisites

For integers d,nd,n, write d∣nd\mid n if n=dkn=dk for some integer kk. Understand division with remainder: for b>0b>0, every integer aa has a unique expression a=qb+ra=qb+r with 0≤r<b0\le r<b. Negative inputs can be replaced by their absolute values when computing a gcd.

Definition and conventions

If a,ba,b are not both zero, gcd⁡(a,b)\gcd(a,b) is the unique positive integer dd dividing both such that every common divisor divides dd. Equivalently, it is their largest positive common divisor. We use the extension gcd⁡(0,0)=0\gcd(0,0)=0 and gcd⁡(a,0)=∣a∣\gcd(a,0)=|a|; this convention keeps the ideal characterization valid even for zero inputs. Two integers are coprime when their gcd is 11, without any requirement that either integer itself be prime.

Intuition

Divisibility is a better guide than numerical size. The gcd gathers exactly the prime powers shared by the inputs, using the smaller exponent at each prime. Yet computing it need not require factoring either input. Repeated remainder operations preserve the common divisors while shrinking the numbers under consideration.

Examples and non-examples

For 252252 and 198198, calculate

252=198+54,198=3⋅54+36,54=36+18.252=198+54,\qquad198=3\cdot54+36,\qquad54=36+18.

The next remainder is zero, so the gcd is 1818. Reversing the equations gives

18=4⋅252−5⋅198.18=4\cdot252-5\cdot198.

Thus 252x+198y=18252x+198y=18 has the solution (4,−5)(4,-5), while 252x+198y=10252x+198y=10 has no integer solution because 18∤1018\nmid10. Although 99 divides both inputs, it is not their gcd: the larger common divisor 1818 does not divide 99.

Important properties

For inputs not both zero, there exist integers u,vu,v with au+bv=dau+bv=d. To see the mechanism, choose the smallest positive integer linear combination. Dividing either input by that combination leaves a remainder that is again a linear combination. Minimality forces each remainder to vanish. Every common divisor divides all such combinations, completing the argument.

Consequently aZ+bZ=dZa\mathbb Z+b\mathbb Z=d\mathbb Z, and ax+by=cax+by=c is solvable precisely when d∣cd\mid c. If gcd⁡(a,m)=1\gcd(a,m)=1, reducing au+mv=1au+mv=1 modulo mm produces a multiplicative inverse of aa. The coprimality hypothesis cannot be omitted.

Connections and further reading

The Euclidean algorithm supplies the gcd and, by back substitution, its linear-combination coefficients. The same viewpoint extends to principal ideal domains, where a gcd is determined up to multiplication by a unit. See Judson, Section 2.2 and Subsection 2.2.1 for the underlying arithmetic statements.