What GCF and LCM mean
The greatest common factor (GCF) — also called the greatest common divisor (GCD) or highest common factor (HCF) — is the largest whole number that divides every number in the list without a remainder. The least common multiple (LCM) is the smallest positive number that every number in the list divides into.
For the default list 12, 18 and 30:
- factors of 12: 1, 2, 3, 4, 6, 12; of 18: 1, 2, 3, 6, 9, 18; of 30: 1, 2, 3, 5, 6, 10, 15, 30 → the largest shared one is 6;
- multiples of 30: 30, 60, 90, 120, 150, 180 — the first that is also a multiple of 12 and 18.
The GCF is what you divide by to simplify a fraction (18/30 = 3/5 after dividing by 6) or to cut things into the largest equal pieces. The LCM gives the common denominator for adding fractions and answers "when do repeating events line up again?" — buses every 12, 18 and 30 minutes all leave together again after 180 minutes.
Method 1: Euclid's algorithm
Euclid's algorithm, more than 2,300 years old, finds the GCF without factoring anything. It relies on one fact: GCF(a, b) = GCF(b, a mod b). Divide the larger number by the smaller, keep the remainder, and repeat with the divisor and the remainder until the remainder is 0. The last non-zero remainder is the GCF.
1071 = 2 × 462 + 147; 462 = 3 × 147 + 21; 147 = 7 × 21 + 0 → GCF = 21
The LCM then follows from the identity
LCM(a, b) = a × b ÷ GCF(a, b)
For more than two numbers both operations are applied one pair at a time: GCF(12, 18, 30) = GCF(GCF(12, 18), 30) = GCF(6, 30) = 6, and LCM(12, 18, 30) = LCM(LCM(12, 18), 30) = LCM(36, 30) = 180. Euclid's method is extremely fast even for huge numbers, which is why computers use it.
Method 2: prime factorization
Write each number as a product of primes:
| Number | Prime factors |
|---|---|
| 12 | 22 × 3 |
| 18 | 2 × 32 |
| 30 | 2 × 3 × 5 |
- GCF: take each prime that appears in every number, with its lowest exponent: 21 × 31 = 6.
- LCM: take every prime that appears anywhere, with its highest exponent: 22 × 32 × 5 = 180.
This method shows why the answers are what they are, and it is the method most textbooks teach. It is slower than Euclid's algorithm for big numbers because factoring is hard, so the calculator uses Euclid for the answer and shows the factor table as an explanation.
A few special cases: numbers whose GCF is 1 are called coprime (8 and 9 are coprime even though neither is prime). Zero is divisible by everything, so it does not change the GCF, but the LCM of any list containing 0 is 0. Negative signs are ignored because divisibility does not depend on sign.
Frequently asked questions
Is GCF the same as GCD and HCF?
Yes. Greatest common factor, greatest common divisor and highest common factor are three names for the same number.
How are GCF and LCM related?
For two positive numbers, GCF × LCM = a × b. For example GCF(12, 18) × LCM(12, 18) = 6 × 36 = 216 = 12 × 18. This identity does not extend directly to three or more numbers.
What is the GCF of two prime numbers?
If they are different primes the GCF is 1 and the LCM is their product, e.g. GCF(7, 11) = 1 and LCM(7, 11) = 77.
Can I use the LCM to add fractions?
Yes — the LCM of the denominators is the least common denominator. To add 1/12 + 1/18, use LCM(12, 18) = 36: 3/36 + 2/36 = 5/36. The fraction calculator does this automatically.
Last reviewed: