Home › Math › GCD and LCM Calculator

GCD and LCM Calculator

Enter two or three positive whole numbers. You get the greatest common divisor, the least common multiple and each number's prime factorization.

Greatest common divisor

—

Least common multiple
—
Prime factorizations
—

Tips for using the gcd and lcm calculator

  • Use the GCD to reduce fractions: 12/18 divided top and bottom by 6 is 2/3.
  • Use the LCM for the lowest common denominator or to find when repeating schedules line up.
  • Two numbers with a GCD of 1 are called coprime.

How the gcd and lcm calculator works

The greatest common divisor (also called greatest common factor) is the largest number that divides all the inputs exactly. The least common multiple is the smallest number they all divide into.

Euclid's algorithm: gcd(a, b) = gcd(b, a mod b), until the remainder is 0
lcm(a, b) = a × b ÷ gcd(a, b)

Euclid's algorithm, over 2,000 years old, is fast even for very large numbers. For three numbers the calculator applies it twice: gcd(a, b, c) = gcd(gcd(a, b), c), and likewise for the LCM. The prime factorizations show the same answer another way: the GCD uses the lowest power of each shared prime and the LCM uses the highest power of every prime that appears.

Worked example

For 12 and 18: 18 mod 12 = 6, then 12 mod 6 = 0, so the GCD is 6. The LCM is 12 × 18 ÷ 6 = 36. In prime factors, 12 = 2² × 3 and 18 = 2 × 3², so the GCD is 2 × 3 = 6 and the LCM is 2² × 3² = 36. Adding fractions like 5/12 + 7/18 uses 36 as the common denominator.

Frequently asked questions

What is the difference between GCD and GCF?

None. Greatest common divisor and greatest common factor are two names for the same thing.

How is LCM related to GCD?

For two numbers, GCD × LCM = a × b.

Can the GCD be 1?

Yes; then the numbers share no prime factors and are coprime, like 8 and 15.

Does this work with negative numbers?

Enter positive whole numbers; the GCD and LCM of negatives are usually defined as positive anyway.

Updated October 2026. Results are estimates for education, not financial or medical advice. All math runs in your browser; nothing you type is sent anywhere.

Related calculators