LCM & GCD Calculator
Greatest common divisor (also called HCF) and least common multiple of any list of integers, using the Euclidean algorithm.
Find the greatest common divisor (GCD/HCF) and least common multiple (LCM) of any list of integers using the Euclidean algorithm.
The Euclidean algorithm in one line
Euclid’s 2300-year-old algorithm is still the fastest way to find the greatest common divisor of two integers. The key fact is that gcd(a, b) = gcd(b, a mod b). Repeat until the second argument is zero, and the first argument is your answer. For more than two numbers, fold the operation: gcd(a, b, c) = gcd(gcd(a, b), c).
From GCD to LCM
The least common multiple is connected to the greatest common divisor by a tidy identity: lcm(a, b) = |a × b| / gcd(a, b). So once you have the GCD, the LCM is one division away.
Why GCD and LCM matter
The GCD shows up whenever you need to simplify a fraction — dividing numerator and denominator by their GCD gives you the canonical lowest-terms form. The LCM shows up whenever you need to add fractions, because the lowest common denominator is the LCM of the original denominators. They also appear in cryptography, music theory (rhythmic resolution), and gear ratios.