The greatest common divisor (GCD) and the least common multiple (LCM) are two core number-theory tools for working with integers. You’ll use the GCD when you want the biggest “shared factor” (for example, to reduce fractions), and the LCM when you want the smallest “shared multiple” (for example, to align repeating schedules or find a common denominator). This calculator accepts a comma-separated list of integers such as 12, 18, 30 and returns both the overall GCD and the overall LCM.
For two nonzero integers a and b, the GCD is commonly computed using the Euclidean algorithm, and the LCM is linked to the GCD by a simple identity:
Relationship between GCD and LCM (two numbers):
Extending to multiple numbers: the calculator reduces a list step-by-step (associatively):
gcd(a, b, c) = gcd(gcd(a, b), c)lcm(a, b, c) = lcm(lcm(a, b), c)Input: 12, 18, 30
Step 1 (GCD):
gcd(12, 18) = 6gcd(6, 30) = 6Result: GCD = 6
Step 2 (LCM):
lcm(12, 18) = |12×18| / gcd(12,18) = 216 / 6 = 36lcm(36, 30) = |36×30| / gcd(36,30)gcd(36, 30) = 6, so lcm = 1080 / 6 = 180Result: LCM = 180
| Concept | Definition (informal) | Common use | Example (12 and 18) |
|---|---|---|---|
| GCD | Largest shared factor | Simplify fractions/ratios; check coprime | gcd(12,18)=6 |
| LCM | Smallest shared multiple | Common denominators; align repeating cycles | lcm(12,18)=36 |
gcd(0, n) = |n|. For LCM, many definitions set lcm(0, n) = 0; if any input is 0, the overall LCM is typically reported as 0.8, 20 → GCD 4, LCM 407, 9, 28 → GCD 1, LCM 252-6, 15 → GCD 3, LCM 300, 12, 18 → GCD 6, LCM 0 (by common convention)