GCD & LCM Calculator
Enter two positive integers to find their greatest common divisor (GCD) and least common multiple (LCM).
How GCD and LCM are calculated
The greatest common divisor (GCD) of two numbers is the largest number that divides both evenly. This calculator finds it using the Euclidean algorithm, which repeatedly replaces the larger number with the remainder of dividing it by the smaller, until the remainder is zero.
The least common multiple (LCM) is the smallest number that's a multiple of both inputs, calculated as LCM = (a × b) / GCD(a, b) — once you know the GCD, the LCM follows directly from this relationship.
Frequently asked questions
What's the GCD of two numbers that share no common factors?
If two numbers have no common factors other than 1 (they're called coprime), their GCD is 1 — for example, GCD(8, 15) = 1.
What are GCD and LCM used for?
GCD is used to simplify fractions to lowest terms; LCM is used to find a common denominator when adding or subtracting fractions, and in scheduling problems involving repeating cycles.
How does the Euclidean algorithm work?
It repeatedly applies GCD(a, b) = GCD(b, a mod b) until b reaches 0 — at that point, a is the GCD. This converges very quickly, even for large numbers.