Glossary Math & Statistics

Greatest common factor (GCF)

The greatest common factor of two numbers is the largest whole number that divides both without a remainder.

Last reviewed:

AdSense Placeholder
Slot: header_reference_page

In more detail

It is also called the greatest common divisor (GCD) or highest common factor. Euclid's method replaces the pair (a, b) by (b, a mod b) until the remainder is 0, and the last non-zero value is the answer: the GCF of 12 and 18 is 6. Alternatively, factor both numbers into primes and multiply the primes they share, each to its lower power. Two numbers whose GCF is 1, such as 8 and 15, are called coprime even though neither is prime.

Why it matters

The GCF simplifies fractions (12/18 = 2/3) and ratios (1920:1080 = 16:9), splits things into the largest equal groups, and is a step in finding the Least common multiple (LCM). Euclid's method stays fast even for numbers with hundreds of digits, which is why cryptographic software uses it; prime factorisation does not scale that way.

Example

GCF of 252 and 105 by Euclid's method:

252 mod 105 = 42
105 mod  42 = 21
 42 mod  21 = 0     →  GCF = 21

Check with primes: 252 = 2² × 3² × 7 and 105 = 3 × 5 × 7 share 3 × 7 = 21. So 252/105 simplifies to 12/5. In Python, math.gcd(252, 105) returns 21.

Common confusion

The Least common multiple (LCM) is the smallest number both divide into; the GCF is the largest number that divides both. For 12 and 18 they are 36 and 6.

AdSense Placeholder
Slot: footer_leaderboard