GCD & LCM Calculator

Find the greatest common divisor (GCD) and least common multiple (LCM) of two or more integers instantly. Enter your numbers to see results with the Euclidean algorithm and prime factorization steps.

How to Use

  1. Enter numbers

    Input two or more positive integers separated by commas.

  2. Calculate

    Click Calculate to find both the GCD and LCM simultaneously.

  3. View results

    The GCD, LCM, and prime factorization steps are displayed.

What are the GCD and LCM?

The greatest common divisor (GCD) is the largest number that divides two or more integers without leaving a remainder, while the least common multiple (LCM) is the smallest positive number that all of those integers divide into evenly.

For example, the common divisors of 12 and 18 are 1, 2, 3, and 6, so the GCD is 6, and the first multiple they share is 36, which is the LCM.

Where is it used?

  • GCD: simplifying fractions, and finding the largest equal group when splitting items evenly
  • LCM: finding a common denominator, and determining when two events with different cycles line up again (for example, bus schedules)

Formula

The GCD is found using the Euclidean algorithm.

GCD(a, b) = GCD(b, a mod b) — repeat until the remainder is 0, and the value at that point is the GCD.

The LCM is derived from the GCD.

LCM(a, b) = |a × b| / GCD(a, b)

Example: 12 and 18

  • GCD: 18 mod 12 = 6 → 12 mod 6 = 0 → GCD = 6
  • LCM: (12 × 18) / 6 = 36

Here a and b are the integers you entered; with three or more numbers, they are combined two at a time in sequence.

Frequently Asked Questions

What is the greatest common divisor (GCD)?
The greatest common divisor is the largest number that is a common divisor of two or more integers. For example, the common divisors of 12 and 18 are 1, 2, 3, and 6, so the GCD is 6. The GCD is used to simplify fractions and reduce ratios.
What is the least common multiple (LCM)?
The least common multiple is the smallest positive number that is a common multiple of two or more integers. For example, the LCM of 12 and 18 is 36. The LCM is used to find common denominators and in cycle calculations, and it can be found with LCM(a,b) = a × b / GCD(a,b).
What is the Euclidean algorithm?
The Euclidean algorithm is an efficient method for finding the GCD. You repeat GCD(a,b) = GCD(b, a mod b), and once the remainder reaches 0, the value at that step is the GCD. Example: GCD(18,12) → GCD(12,6) → GCD(6,0) = 6. Proposed by Euclid around 300 BC, it is one of the oldest algorithms known.
What is the relationship between the GCD and the LCM?
For two numbers a and b, the relationship GCD(a,b) × LCM(a,b) = a × b holds. In other words, the product of the GCD and LCM equals the product of the original two numbers. Thanks to this property, once you have the GCD you can obtain the LCM with a single multiplication and division.
Can it calculate three or more numbers?
Yes, this calculator accepts up to 10 numbers. Just enter them separated by commas or spaces. The GCD and LCM of several numbers are computed by combining them two at a time from the start, like GCD(GCD(a,b),c).
What happens when two numbers are coprime?
When the only common divisor of two numbers is 1, they are called coprime, and in that case the GCD is 1. For coprime numbers, the LCM is simply the product of the two numbers (a × b). For example, 8 and 9 are coprime, so their GCD is 1 and their LCM is 72.
Verified 2026 formulas

Related Calculators