Free online formula calculators

GCD and LCM Calculator

Enter two or more whole numbers to find their greatest common divisor and least common multiple.

GCD and LCM Calculator
Separate values with commas, spaces or new lines.
Result
Greatest common divisor12
Least common multiple360
Relatively prime?No — all share the factor 12

Link to this calculation

Formula

gcd(a, b) = gcd(b, a mod b), gcd(a, 0) = a
lcm(a, b) = |a × b| ÷ gcd(a, b)
SymbolMeaning
gcdLargest whole number that divides every input exactly
lcmSmallest positive whole number that every input divides
a mod bRemainder when a is divided by b

How to Use This Calculator

  1. Type or paste the Whole numbers. Separate numbers with commas or spaces.
  2. Press Calculate. Results also update automatically as you type.

Worked Example

Using the values pre-filled in the calculator above:

Inputs
Whole numbers24, 36, 60
Results
Greatest common divisor12
Least common multiple360
Relatively prime?No — all share the factor 12

About This Calculation

The greatest common divisor (GCD) — also called the greatest common factor (GCF) or highest common factor (HCF) — is the largest whole number that divides each of your numbers without a remainder. The least common multiple (LCM) is the smallest positive number that all of them divide into. For 24, 36 and 60 the GCD is 12 and the LCM is 360.

This calculator uses the Euclidean algorithm, one of the oldest algorithms still in everyday use: repeatedly replace the larger number with the remainder of dividing it by the smaller, until the remainder is zero. It is far faster than listing factors, especially for large numbers. For two numbers, GCD × LCM equals their product, so once you have one you have the other — but that shortcut does not hold for three or more numbers. When the GCD is 1, the numbers are called relatively prime (or coprime), even if neither is itself prime.

The GCD is what you divide by to reduce a fraction or ratio to lowest terms, and to cut material into the largest equal pieces with no waste. The LCM gives the lowest common denominator for adding fractions, and answers scheduling questions such as when two buses with different intervals will next leave together.

Frequently Asked Questions

What is the GCD of two prime numbers?
If they are different primes the GCD is 1, and their LCM is simply their product. For example gcd(7, 13) = 1 and lcm(7, 13) = 91.
Can I use negative numbers?
Yes. Divisibility ignores sign, so this calculator uses absolute values; the GCD and LCM are reported as positive numbers. Zero is not allowed because every number divides zero.

Category: Math & Algebra. Found a problem with this calculator? Let us know.