Visual Tools
Calculators
Tables
Mathematical Keyboard
Converters
Other Tools


Greatest Common Divisor (GCD)






The Largest Shared Divisor

When two numbers share common factors, the greatest among them captures the deepest structural connection between the pair. The greatest common divisor — GCD — measures how much two numbers overlap in their factor structure, and it appears everywhere from simplifying fractions to determining whether two quantities are fundamentally incompatible.



What is GCD?

The greatest common divisor of two positive integers aa and bb, written gcd(a,b)\gcd(a, b), is the largest positive integer that divides both.

The common factors of 1212 and 1818 are {1,2,3,6}\{1, 2, 3, 6\}. The largest is 66, so gcd(12,18)=6\gcd(12, 18) = 6.

The common factors of 2020 and 3535 are {1,5}\{1, 5\}. The largest is 55, so gcd(20,35)=5\gcd(20, 35) = 5.

The GCD always exists for any pair of positive integers, and it is always at least 11 — because 11 divides everything. It can never exceed the smaller of the two numbers, since no factor of aa can be larger than aa itself.

The same concept goes by several names. GCD (greatest common divisor) is standard in most mathematical texts. HCF (highest common factor) is common in British usage. GCF (greatest common factor) appears in some textbooks. All three refer to the same quantity.

Basic Properties

Several properties follow directly from the definition and hold for all positive integers.

gcd(a,a)=a\gcd(a, a) = a. The largest number dividing aa and aa is aa itself.

gcd(a,1)=1\gcd(a, 1) = 1. The only positive divisor of 11 is 11, so the only common divisor is 11.

gcd(a,0)=a\gcd(a, 0) = a. Every positive integer divides 00, so the common divisors of aa and 00 are exactly the divisors of aa. The largest is aa.

gcd(a,b)=gcd(b,a)\gcd(a, b) = \gcd(b, a). Order is irrelevant — the common factors of aa and bb are the same as those of bb and aa.

gcd(a,b)min(a,b)\gcd(a, b) \leq \min(a, b). No common divisor can exceed the smaller number.

One further property connects the GCD to all other common divisors: every common divisor of aa and bb also divides gcd(a,b)\gcd(a, b). The GCD is not just the largest common divisor — it is a multiple of every common divisor.

Method 1: Listing Factors

The most direct approach finds all factors of each number, identifies the overlap, and selects the largest.

For gcd(24,36)\gcd(24, 36):

Factors of 2424: {1,2,3,4,6,8,12,24}\{1, 2, 3, 4, 6, 8, 12, 24\}.

Factors of 3636: {1,2,3,4,6,9,12,18,36}\{1, 2, 3, 4, 6, 9, 12, 18, 36\}.

Common factors: {1,2,3,4,6,12}\{1, 2, 3, 4, 6, 12\}.

The largest is 1212, so gcd(24,36)=12\gcd(24, 36) = 12.

The method is transparent and reliable for small numbers. For large numbers it becomes impractical — finding all factors of a number like 1,7641{,}764 requires systematic testing up to 176442\sqrt{1764} \approx 42, and doing this for two numbers is tedious. The methods that follow avoid listing factors entirely.

Method 2: Prime Factorization

The prime factorization of each number reveals exactly which primes they share and in what quantities. The GCD takes the minimum exponent for each common prime.

For gcd(48,180)\gcd(48, 180):

48=243148 = 2^4 \cdot 3^1

180=223251180 = 2^2 \cdot 3^2 \cdot 5^1

The primes appearing in both factorizations are 22 and 33. The prime 55 appears only in 180180 and contributes nothing to the GCD.

Take the smaller exponent for each shared prime: min(4,2)=2\min(4, 2) = 2 for the prime 22, and min(1,2)=1\min(1, 2) = 1 for the prime 33.

gcd(48,180)=2231=43=12\gcd(48, 180) = 2^2 \cdot 3^1 = 4 \cdot 3 = 12


This method is efficient when the factorizations are easy to find. For numbers whose prime factors are not immediately apparent, the Euclidean algorithm is faster.

Method 3: Euclidean Algorithm

The Euclidean algorithm computes the GCD without factoring either number. It relies on a single property: gcd(a,b)=gcd(b,  amodb)\gcd(a, b) = \gcd(b, \; a \bmod b). Replacing the larger number with the remainder of their division preserves the GCD while shrinking the problem.

For gcd(252,105)\gcd(252, 105):

252=1052+42252 = 105 \cdot 2 + 42, so gcd(252,105)=gcd(105,42)\gcd(252, 105) = \gcd(105, 42).

105=422+21105 = 42 \cdot 2 + 21, so gcd(105,42)=gcd(42,21)\gcd(105, 42) = \gcd(42, 21).

42=212+042 = 21 \cdot 2 + 0, so gcd(42,21)=21\gcd(42, 21) = 21.

The last nonzero remainder is 2121, which is gcd(252,105)\gcd(252, 105).

The algorithm works because any common divisor of aa and bb is also a common divisor of bb and amodba \bmod b. The modulo operation peels away multiples of bb from aa, leaving a smaller number with the same common divisor structure. This is the most efficient of the three methods, particularly for large numbers where factorization is difficult.

Euclidean Algorithm Step by Step

The procedure is mechanical. Start with two positive integers aa and bb, with aba \geq b.

Compute r=amodbr = a \bmod b. Replace aa with bb and bb with rr. Repeat until b=0b = 0. The value of aa at that point is the GCD.

For gcd(462,198)\gcd(462, 198):

462=1982+66a=198,  b=66462 = 198 \cdot 2 + 66 \quad \to \quad a = 198, \; b = 66

198=663+0b=0198 = 66 \cdot 3 + 0 \quad \to \quad b = 0

gcd(462,198)=66\gcd(462, 198) = 66.

For gcd(1,071,462)\gcd(1{,}071, 462):

1071=4622+147a=462,  b=1471071 = 462 \cdot 2 + 147 \quad \to \quad a = 462, \; b = 147

462=1473+21a=147,  b=21462 = 147 \cdot 3 + 21 \quad \to \quad a = 147, \; b = 21

147=217+0b=0147 = 21 \cdot 7 + 0 \quad \to \quad b = 0

gcd(1071,462)=21\gcd(1071, 462) = 21.

The algorithm always terminates because the remainder rr satisfies 0r<b0 \leq r < b, so bb strictly decreases at each step. A sequence of positive integers that strictly decreases must eventually reach zero.

Coprime (Relatively Prime) Numbers

Two numbers are coprime — also called relatively prime — when their GCD is 11. They share no common factor except the trivial one.

The numbers 88 and 1515 are coprime: the factors of 88 are {1,2,4,8}\{1, 2, 4, 8\}, the factors of 1515 are {1,3,5,15}\{1, 3, 5, 15\}, and the only overlap is 11.

The numbers 99 and 1212 are not coprime: gcd(9,12)=3\gcd(9, 12) = 3.

The numbers 77 and 2020 are coprime: 77 is prime and does not divide 2020.

Two structural facts generate coprime pairs reliably. Any two consecutive integers are coprime — gcd(n,n+1)=1\gcd(n, n+1) = 1 for all nn — because any common divisor of nn and n+1n+1 would have to divide their difference, which is 11. And a prime pp is coprime with every number it does not divide.

Properties of Coprime Numbers

Coprimality enables conclusions that fail for numbers with shared factors.

If gcd(a,b)=1\gcd(a, b) = 1 and a(bc)a \mid (b \cdot c), then aca \mid c. When aa and bb share no common factor, the factor aa hiding inside the product bcb \cdot c must come entirely from cc. Without coprimality, this inference breaks — 6(43)6 \mid (4 \cdot 3) does not imply 636 \mid 3.

If gcd(a,b)=1\gcd(a, b) = 1 and gcd(a,c)=1\gcd(a, c) = 1, then gcd(a,bc)=1\gcd(a, b \cdot c) = 1. Coprimality with individual factors extends to their product.

If gcd(a,b)=1\gcd(a, b) = 1, then gcd(a2,b2)=1\gcd(a^2, b^2) = 1. Squaring both numbers introduces no new shared primes.

These properties are essential in the theory of divisibility. The rule that divisibility by 66 can be tested by checking 22 and 33 separately works precisely because gcd(2,3)=1\gcd(2, 3) = 1. Coprimality is what makes the combined divisibility rules valid.

GCD of More Than Two Numbers

The GCD extends to any number of inputs by applying it pairwise. The key identity is:

gcd(a,b,c)=gcd(gcd(a,b),  c)\gcd(a, b, c) = \gcd(\gcd(a, b), \; c)


Compute the GCD of the first two numbers, then take the GCD of that result with the third number. The process chains to any length.

For gcd(24,36,60)\gcd(24, 36, 60):

gcd(24,36)=12\gcd(24, 36) = 12.

gcd(12,60)=12\gcd(12, 60) = 12.

So gcd(24,36,60)=12\gcd(24, 36, 60) = 12.

For gcd(18,30,42)\gcd(18, 30, 42):

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

gcd(6,42)=6\gcd(6, 42) = 6.

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

The order of pairing does not matter — the GCD is associative and commutative, so any grouping produces the same result.

Applications of GCD

The most immediate application is simplifying fractions. The fraction 2436\frac{24}{36} reduces to 23\frac{2}{3} by dividing numerator and denominator by gcd(24,36)=12\gcd(24, 36) = 12. A fraction is in lowest terms when the GCD of its numerator and denominator is 11.

Ratios simplify the same way. A rectangle with dimensions 48×8048 \times 80 has an aspect ratio of 48:8048:80. Dividing both by gcd(48,80)=16\gcd(48, 80) = 16 gives 3:53:5.

Tiling problems use the GCD geometrically. The largest square tile that fits perfectly into a 48×8048 \times 80 rectangle has side length gcd(48,80)=16\gcd(48, 80) = 16. The rectangle can be covered by 3×5=153 \times 5 = 15 such tiles with no gaps or overlaps.

The GCD also connects to the LCM through a clean identity: ab=gcd(a,b)lcm(a,b)a \cdot b = \gcd(a, b) \cdot \text{lcm}(a, b). Knowing the GCD gives the LCM for free, and vice versa.

Worked Examples

Find gcd(56,84)\gcd(56, 84) by listing factors. Factors of 5656: {1,2,4,7,8,14,28,56}\{1, 2, 4, 7, 8, 14, 28, 56\}. Factors of 8484: {1,2,3,4,6,7,12,14,21,28,42,84}\{1, 2, 3, 4, 6, 7, 12, 14, 21, 28, 42, 84\}. Common: {1,2,4,7,14,28}\{1, 2, 4, 7, 14, 28\}. GCD =28= 28.

Find gcd(120,84)\gcd(120, 84) by prime factorization. 120=2335120 = 2^3 \cdot 3 \cdot 5 and 84=223784 = 2^2 \cdot 3 \cdot 7. Shared primes: 2min(3,2)3min(1,1)=223=122^{\min(3,2)} \cdot 3^{\min(1,1)} = 2^2 \cdot 3 = 12.

Find gcd(782,253)\gcd(782, 253) by the Euclidean algorithm. 782=2533+23782 = 253 \cdot 3 + 23. Then 253=2311+0253 = 23 \cdot 11 + 0. GCD =23= 23.

Are 3535 and 5454 coprime? gcd(35,54)\gcd(35, 54): 54=351+1954 = 35 \cdot 1 + 19, 35=191+1635 = 19 \cdot 1 + 16, 19=161+319 = 16 \cdot 1 + 3, 16=35+116 = 3 \cdot 5 + 1, 3=13+03 = 1 \cdot 3 + 0. GCD =1= 1. Yes, coprime.

Simplify 84126\frac{84}{126}. gcd(84,126)\gcd(84, 126): 126=841+42126 = 84 \cdot 1 + 42, 84=422+084 = 42 \cdot 2 + 0. GCD =42= 42. The fraction reduces to 23\frac{2}{3}.