GCD and LCM Calculator
Find the greatest common divisor and least common multiple of two numbers.
Comment ça marche
The Greatest Common Divisor (GCD) of two numbers is the largest number that divides both evenly with no remainder. The Least Common Multiple (LCM) is the smallest number that both original numbers divide into evenly. This calculator finds both at once from any two whole numbers.
GCD is found using the Euclidean algorithm, a method known since ancient Greece: repeatedly divide the larger number by the smaller and replace the larger with the remainder, until the remainder is zero — the last non-zero remainder is the GCD. For 48 and 18: 48 ÷ 18 leaves remainder 12; 18 ÷ 12 leaves remainder 6; 12 ÷ 6 leaves remainder 0 — so GCD(48, 18) = 6.
Once GCD is known, LCM follows directly from the relationship GCD(a,b) × LCM(a,b) = a × b, so LCM = (a × b) ÷ GCD. For 48 and 18, that's (48 × 18) ÷ 6 = 864 ÷ 6 = 144.
GCD is exactly the tool used to simplify a fraction to lowest terms — dividing both numerator and denominator by their GCD always produces the fully reduced form in one step, which is precisely how the Fraction Calculator's simplification works internally.
LCM shows up whenever you need a common ground between repeating cycles — finding a common denominator to add fractions with different denominators, or figuring out when two repeating events (like two buses on different schedules, or two blinking lights with different intervals) will next align.
Two special cases are worth knowing: if two numbers share no common factors other than 1, they're called coprime, and their GCD is 1 while their LCM is simply their product. And if one number divides the other evenly (like 4 and 12), the smaller number is the GCD and the larger is the LCM.
What if one number is zero?
The GCD of a number and zero is the other number; LCM is undefined (shown as 0) when either input is zero.
What is the Euclidean algorithm?
An ancient, efficient method for finding GCD: repeatedly divide the larger number by the smaller, replacing the larger with the remainder, until the remainder reaches zero — the last non-zero remainder is the GCD.
How is LCM calculated once I know the GCD?
LCM = (a × b) ÷ GCD(a,b) — this relationship always holds for any two positive whole numbers.
What does it mean for two numbers to be coprime?
Coprime numbers share no common factors other than 1 — their GCD is always 1, and their LCM is simply the product of the two numbers.
How is GCD used to simplify fractions?
Dividing both the numerator and denominator of a fraction by their GCD reduces it to lowest terms in a single step — this is exactly how automatic fraction simplification works.
When would I need to find the LCM of two numbers in real life?
Common uses include finding a shared denominator to add fractions, or determining when two repeating cycles (like schedules or intervals) will next coincide.
Can GCD and LCM be calculated for more than two numbers?
Yes, conceptually — find the GCD or LCM of the first two numbers, then combine that result with the next number, repeating until all numbers are included. This calculator handles two numbers at a time.
What if one number divides evenly into the other?
Then the smaller number is automatically the GCD, and the larger number is automatically the LCM — for example, GCD(4, 12) = 4 and LCM(4, 12) = 12.
Does the order of the two numbers matter?
No — GCD(a,b) always equals GCD(b,a), and the same is true for LCM, so entering the numbers in either order gives the same result.
Is there another way to find GCD besides the Euclidean algorithm?
Yes — prime factorization works too: break both numbers into their prime factors, then GCD is the product of shared primes (at their lowest shared power), and LCM is the product of all primes involved (at their highest power). The Euclidean algorithm is generally faster for larger numbers.
Why is the Euclidean algorithm considered efficient?
It converges quickly even for very large numbers, needing relatively few division steps regardless of how big the inputs are — much faster than checking every possible common divisor one by one.