LCM and GCF Calculator
The greatest common factor and least common multiple of two or more numbers.
Good to know. Two buses every 12 and 18 minutes leave together again every 36 minutes. That’s the LCM at work.
How it works
In plain words
The GCF is the largest number that divides all of them, found with Euclid’s algorithm: replace the larger number with the remainder of dividing it by the smaller, until the remainder is 0. The LCM of two numbers is their product divided by their GCF; for more numbers, repeat pair by pair.
The formula
gcf(a, b) = gcf(b, a mod b), gcf(a, 0) = a lcm(a, b) = a × b ÷ gcf(a, b)
Worked example
12 = 2² × 3, 18 = 2 × 3² and 30 = 2 × 3 × 5. The factors they share are 2 and 3, so the GCF is 6. The LCM, using each prime at its highest power, is 2² × 3² × 5 = 180.
Sources
No outside data or rates: this is plain arithmetic.
4 automated tests check its answers on every change.
About the LCM and GCF calculator
The greatest common factor (GCF) is the largest whole number that divides every number in a list. It is also called the greatest common divisor (GCD) or, in the UK, the highest common factor (HCF). The least common multiple (LCM) is the smallest number that every number in the list divides into.
You use the GCF to simplify fractions (divide top and bottom by it: 18/30 = 3/5) and to split things into equal groups without leftovers. You use the LCM to add fractions with different denominators, and for anything that repeats on different cycles: two buses leaving every 12 and 18 minutes leave together again every 36 minutes.
Both are easy to see from prime factors, shown in the table. The GCF uses the primes the numbers share, each at its lowest power. The LCM uses every prime that appears, each at its highest power. For large numbers, the calculator uses Euclid’s algorithm, which is fast even for numbers in the billions.
Numbers whose only common factor is 1, like 8 and 15, are called coprime. Their LCM is simply their product.
Questions people ask
How do I find the GCF of two numbers?
List the prime factors of each and multiply the ones they share. For 12 and 18: 2 × 3 = 6.
How do I find the LCM of two numbers?
Multiply them and divide by their GCF. For 12 and 18: 216 ÷ 6 = 36.
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.