In short
The greatest common factor (GCF) is the largest whole number that divides every number in a list. The least common multiple (LCM) is the smallest number that every number in the list divides into. Write each number as a product of primes: the GCF uses each shared prime at its lowest power, and the LCM uses every prime at its highest power.
How it works
Every whole number above 1 can be written as a product of primes in exactly one way, for example 120 = 2³ × 3 × 5. Once you have the factorizations, both answers follow directly.
GCF = product of shared primes, each at its lowest power LCM = product of all primes, each at its highest power
For 54 = 2 × 3³ and 36 = 2² × 3², the shared primes are 2 and 3. Their lowest powers are 2¹ and 3², so the GCF is 2 × 9 = 18. The highest powers are 2² and 3³, so the LCM is 4 × 27 = 108.
For large numbers, factoring is slow, so the calculator finds the GCF with Euclid’s algorithm: replace the larger number with the remainder after dividing by the smaller, and repeat until the remainder is 0.
gcd(a, b) = gcd(b, a mod b), gcd(a, 0) = a lcm(a, b) = a × b ÷ gcd(a, b)
With three or more numbers, the calculator applies these pairwise: gcd(a, b, c) = gcd(gcd(a, b), c), and the same for the LCM.
Worked examples
The GCF of 54 and 36
54 = 2 × 3³ and 36 = 2² × 3². Both contain 2 and 3. Taking the lower power of each gives 2 × 3² = 18. This is Example 7.1 in OpenStax Elementary Algebra. Euclid’s algorithm agrees: 54 mod 36 = 18, and 36 mod 18 = 0.
The LCM of 15 and 18
15 = 3 × 5 and 18 = 2 × 3². The LCM needs 2, 3² and 5: 2 × 9 × 5 = 90. As a check, 15 × 18 = 270, and 270 ÷ GCF 3 = 90.
When three bus routes next leave together
Buses leave a station every 12, 20 and 30 minutes, all at 8:00. They leave together again after the LCM of 12, 20 and 30 minutes. 12 = 2² × 3, 20 = 2² × 5 and 30 = 2 × 3 × 5, so the LCM is 2² × 3 × 5 = 60 minutes, at 9:00.
Using this calculator well
- Adding fractions uses the LCM. The least common denominator of 5/12 and 7/18 is the LCM of 12 and 18, which is 36. Using it keeps the numbers small: 15/36 + 14/36 = 29/36.
- Simplifying fractions uses the GCF. Divide the top and bottom by their GCF to reduce in one step: GCF(36, 54) = 18, so 36/54 = 2/3.
- GCF, GCD and HCF are the same thing. US schools say greatest common factor, mathematicians say greatest common divisor, and UK and Indian textbooks say highest common factor.
- The GCF can never exceed the smallest number, and the LCM is never below the largest. If an answer breaks either rule, a number was mistyped.
Frequently asked questions
What is the difference between LCM and GCF?
The GCF is the largest number that divides into all of your numbers, so it is at most the smallest of them. The LCM is the smallest number that all of yours divide into, so it is at least the largest. For 12 and 18, the GCF is 6 and the LCM is 36.
How do you find the LCM of three numbers?
Factor each into primes and multiply every prime at the highest power it appears. For 12, 20 and 30, the primes are 2² (from 12 and 20), 3 and 5, so the LCM is 4 × 3 × 5 = 60. Alternatively, find the LCM of the first two and then the LCM of that result with the third.
Is GCD the same as GCF or HCF?
Yes. Greatest common divisor, greatest common factor and highest common factor are three names for the same number. Which one you see depends on the country and the level of the course, but the calculation is identical.
What does it mean if the GCF is 1?
The numbers share no prime factor, so they are called relatively prime or coprime. 8 and 15 are an example, even though neither is prime. For two coprime numbers, the LCM is simply their product, here 120.
Why is LCM times GCF equal to the product of two numbers?
For each prime, the GCF takes the smaller of the two exponents and the LCM takes the larger. Together they use both exponents exactly once, just like multiplying the numbers. So 12 × 18 = 216 = 6 × 36. This only holds for two numbers, not three or more.
Sources and methodology
- Prealgebra 2e, 2.5 Prime Factorization and the Least Common Multiple, OpenStax, Rice University, Examples 2.48–2.54: 48 = 2⁴ × 3, 120 = 2³ × 3 × 5; LCM(15, 20) = 60, LCM(15, 18) = 90, LCM(50, 100) = 100 (accessed November 24, 2026)
- Elementary Algebra 2e, 7.1 Greatest Common Factor and Factor by Grouping, OpenStax, Rice University, Example 7.1: the GCF of 54 and 36 is 18 (accessed November 24, 2026)
Rounding: No rounding: whole-number arithmetic is exact, and the LCM is computed with arbitrary-precision integers however large it gets.
Review status: formulas verified against the cited sources by automated tests; editorial review pending. Version 1.0.0, content updated November 24, 2026.
Changelog
- 1.0.0 · November 24, 2026: First published.
How we build and test calculators
Embed this calculator on your site
Paste this code into your page. The calculator runs in a frame, with no tracking and no cookies, and links back here for the formula and sources.
<iframe src="https://northcalculator.com/embed/en/lcm-gcf" title="LCM and GCF Calculator" width="100%" height="760" style="border:0" loading="lazy"></iframe>