LCM and GCF in one minute
The greatest common factor (GCF) of a set of numbers is the largest whole number that divides each of them without a remainder. Many books call it the greatest common divisor (GCD) or highest common factor (HCF). The least common multiple (LCM) is the smallest positive number that each of them divides into. For 12, 18 and 30, the GCF is 6 and the LCM is 180.
A quick sanity check: the GCF can never be larger than your smallest number, and the LCM can never be smaller than your largest number. If the GCF equals the smallest number, that number divides all the others, and if the LCM equals the largest number, all the others divide it.
Method 1: prime factorization
Break every number into primes, for example with the prime factorization calculator, and line the primes up in a table:
| Number | 2 | 3 | 5 |
|---|---|---|---|
| 12 | 2² | 3 | none |
| 18 | 2 | 3² | none |
| 30 | 2 | 3 | 5 |
For the GCF, take each prime that appears in every number at its lowest power: 2 × 3 = 6. The 5 is missing from 12 and 18, so it does not count. For the LCM, take every prime that appears anywhere at its highest power: 2² × 3² × 5 = 180. This method shows why the answers are right, and it works for any number of values at once.
Method 2: the Euclidean algorithm
For large numbers, factoring is slow. The Euclidean algorithm finds the GCF with nothing but division. Divide the larger number by the smaller one, then divide the smaller one by the remainder, and repeat until the remainder is 0. The last remainder that was not 0 is the GCF.
- 252 = 1 × 198 + 54
- 198 = 3 × 54 + 36
- 54 = 1 × 36 + 18
- 36 = 2 × 18 + 0, so the GCF of 252 and 198 is 18.
It works because any number that divides both 252 and 198 also divides their difference, and so the remainder 54. Each line keeps the same common factors while the numbers shrink. The method is very old: Euclid describes it as repeated subtraction in Book VII, Proposition 2 of the Elements, and dividing simply does many subtractions at once.
Once you have the GCF of two numbers, the LCM follows from LCM = a × b ÷ GCF. For 252 and 198 that is 252 × 198 ÷ 18 = 2,772. With more than two numbers, go in pairs: the GCF of 12, 18 and 30 is the GCF of GCF(12, 18) = 6 and 30, and the LCM works the same way.
Method 3: listing factors and multiples
With small numbers you can simply write things out. List all factors of each number and pick the largest one they share: the factors of 12 are 1, 2, 3, 4, 6, 12 and those of 18 are 1, 2, 3, 6, 9, 18, so the GCF is 6. For the LCM, list multiples until one shows up in every list: 12, 24, 36 and 18, 36, so the LCM is 36. Listing gets long quickly, so the calculator only shows it when the lists stay short.
Zero, one and negative numbers
Every whole number divides 0, so a 0 in your list does not change the GCF: the GCF of 0 and 15 is 15. The only multiple 0 has is 0 itself, so the LCM of a list that contains 0 is 0 by convention. If every number is 0, the GCF is not defined, because there is no largest number that divides 0. Negative numbers have the same factors as their positive versions, so the calculator uses the absolute values and gives the LCM and GCF as positive numbers. The number 1 has no prime factors, which means a GCF of 1 tells you the numbers share no prime at all.
A shortcut for two numbers
For exactly two numbers, the GCF and LCM are tied together: GCF × LCM = a × b. The reason is that for every prime, the GCF takes the smaller exponent and the LCM takes the larger one, so between them they use both exponents once, just like the product does. For 12 and 18: 6 × 36 = 216 = 12 × 18. So once you know one of the two, the other is a single division away: LCM = 12 × 18 ÷ 6 = 36. This shortcut does not hold for three or more numbers, which is why the calculator works in pairs there.
Where you need them
Fractions are the classic case. To add 5/12 + 7/18, rewrite both with the LCM of 12 and 18, 36, as the denominator: 15/36 + 14/36 = 29/36. To simplify 12/18, divide top and bottom by the GCF, 6, to get 2/3. The fraction calculator does both with steps. Outside the classroom, the GCF tells you the largest equal groups you can make, like the largest square tile that fits a 252 by 198 cm floor exactly (18 cm), and the LCM tells you when repeating events line up again.
How to use the LCM and GCF calculator
- 1Type 2 to 10 whole numbers, separated by commas or spaces, like 12, 18, 30.
- 2Read the LCM and GCF at the top. The results update as you type.
- 3Pick a method below to see the steps: a prime factor table, the Euclidean algorithm or listing factors and multiples. Copy the result with the steps, or copy a link to share it.
Frequently asked questions
What is the difference between LCM and GCF?
The greatest common factor (GCF) is the largest number that divides all of your numbers. The least common multiple (LCM) is the smallest number that all of your numbers divide into. For 12 and 18 the GCF is 6 and the LCM is 36. The GCF is never larger than the smallest number, and the LCM is never smaller than the largest.
Is GCF the same as GCD and HCF?
Yes. Greatest common factor (GCF), greatest common divisor (GCD) and highest common factor (HCF) are three names for the same number. Which one you see depends on the textbook.
What does it mean when the GCF is 1?
The numbers share no prime factor. They are called relatively prime or coprime, like 8 and 9. The numbers themselves do not have to be prime: 8 and 9 are both composite. For two coprime numbers, the LCM is simply their product, here 72.
How do I find the LCM of three or more numbers?
Work in pairs: find the LCM of the first two, then the LCM of that result and the third number, and so on. Or use prime factorization and take every prime that appears at its highest power. Both ways give the same answer, and the calculator shows each of them.
Why is GCF × LCM equal to the product of the two numbers?
For each prime, the GCF takes the smaller exponent and the LCM takes the larger one. Together they use both exponents, exactly like the product of the two numbers does. So 6 × 36 = 12 × 18 = 216. This only works for two numbers, not for three or more.
What are LCM and GCF used for?
The LCM of the denominators is the least common denominator you need to add fractions like 1/12 + 1/18. The GCF simplifies a fraction in one step: 12/18 divided top and bottom by 6 is 2/3. The LCM also answers timing questions, like when two buses that leave every 12 and 18 minutes leave together again (after 36 minutes).