Skip to content

Greatest Common Divisors

Let $a$ and $b$ be integers, not both zero. An integer $d$ is called a common divisor of $a$ and $b$ if

Common Divisors

Let aa and bb be integers, not both zero. An integer dd is called a common divisor of aa and bb if

da d\mid a

and

db. d\mid b.

For example, the positive divisors of 1818 are

1,2,3,6,9,18, 1,2,3,6,9,18,

and the positive divisors of 3030 are

1,2,3,5,6,10,15,30. 1,2,3,5,6,10,15,30.

Their common positive divisors are

1,2,3,6. 1,2,3,6.

The largest of these is 66. Hence

gcd(18,30)=6. \gcd(18,30)=6.

Definition

The greatest common divisor of two integers aa and bb, not both zero, is the largest positive integer dd such that

da d\mid a

and

db. d\mid b.

It is denoted by

gcd(a,b). \gcd(a,b).

The condition that dd be positive removes the ambiguity caused by signs. If dd divides both aa and bb, then d-d also divides both. The greatest common divisor is chosen to be positive.

For example,

gcd(12,18)=6,gcd(12,18)=6. \gcd(12,18)=6, \qquad \gcd(-12,18)=6.

Basic Examples

If one integer divides the other, the greatest common divisor is the smaller integer in absolute value. For example,

gcd(8,24)=8. \gcd(8,24)=8.

If two integers share no positive divisor greater than 11, their greatest common divisor is 11. For example,

gcd(14,25)=1. \gcd(14,25)=1.

If a0a\ne0, then

gcd(a,0)=a. \gcd(a,0)=|a|.

This follows because every integer divides 00, and the positive divisors of aa are exactly the possible common positive divisors of aa and 00.

Existence

The greatest common divisor always exists for two integers not both zero.

Indeed, the set of positive common divisors of aa and bb is nonempty because 11 divides every integer. It is also finite, since any positive divisor of a nonzero integer aa is at most a|a|. If a=0a=0, then b0b\ne0, and any common divisor is at most b|b|.

Therefore the positive common divisors form a finite nonempty set, so they have a largest element.

Symmetry and Sign

The greatest common divisor is symmetric:

gcd(a,b)=gcd(b,a). \gcd(a,b)=\gcd(b,a).

It is also insensitive to signs:

gcd(a,b)=gcd(a,b). \gcd(a,b)=\gcd(|a|,|b|).

For example,

gcd(21,35)=gcd(21,35)=7. \gcd(-21,35)=\gcd(21,35)=7.

Thus one may usually reduce questions about greatest common divisors to positive integers.

Coprime Integers

Two integers aa and bb are called coprime, or relatively prime, if

gcd(a,b)=1. \gcd(a,b)=1.

For example,

gcd(8,15)=1, \gcd(8,15)=1,

so 88 and 1515 are coprime.

Coprime integers need not be prime individually. The integers 88 and 1515 are both composite, yet they share no common positive divisor greater than 11.

Coprimality measures shared factor structure, not primality of the individual numbers.

Prime Factorization View

If the prime factorizations of aa and bb are known, their greatest common divisor can be read off directly.

For example,

72=2332 72=2^3\cdot3^2

and

120=2335. 120=2^3\cdot3\cdot5.

The common prime powers are

23and3. 2^3 \quad\text{and}\quad 3.

Therefore

gcd(72,120)=233=24. \gcd(72,120)=2^3\cdot3=24.

In general, the greatest common divisor contains exactly the prime powers that occur in both integers, with the smaller exponent chosen.

Divisibility Characterization

If

d=gcd(a,b), d=\gcd(a,b),

then every common divisor of aa and bb divides dd.

This property is deeper than the definition as the largest common divisor. It will follow naturally from Bézout identities after the Euclidean algorithm is developed.

For example, since

gcd(18,30)=6, \gcd(18,30)=6,

every common divisor of 1818 and 3030 divides 66.

The common divisors are therefore precisely the divisors of the greatest common divisor.

Greatest Common Divisors and Linear Combinations

A central theorem states that gcd(a,b)\gcd(a,b) can be written as an integer linear combination of aa and bb:

gcd(a,b)=ax+by \gcd(a,b)=ax+by

for some integers xx and yy.

For example,

gcd(18,30)=6 \gcd(18,30)=6

and

6=3018. 6=30-18.

Thus

6=(1)18+130. 6=(-1)18+1\cdot30.

This representation is known as Bézout’s identity. It gives the greatest common divisor a constructive form and is one of the most useful facts in elementary number theory.

Role in Number Theory

Greatest common divisors measure the shared arithmetic content of integers. They occur in divisibility problems, reduction of fractions, modular inverses, Diophantine equations, and the Chinese remainder theorem.

For example, the fraction

ab \frac{a}{b}

is in lowest terms precisely when

gcd(a,b)=1. \gcd(a,b)=1.

A linear congruence

axc(modn) ax\equiv c\pmod n

is solvable exactly when

gcd(a,n)c. \gcd(a,n)\mid c.

Thus the greatest common divisor is one of the main organizing invariants of elementary number theory.