GCD & LCM Calculator
Greatest common divisor and least common multiple.
What is the GCD & LCM Calculator?
The greatest common divisor (GCD) is the largest number that evenly divides two or more integers, while the least common multiple (LCM) is the smallest number that is a multiple of all of them. This tool accepts comma-separated integers and computes both instantly.
How to use it
Enter two or more positive integers separated by commas, e.g. 12, 18, 24, then press Calculate. Decimals, negatives, and zero are not accepted.
Formula & process
Euclidean algorithm: GCD(a, b) = GCD(b, a mod b), repeated until b is 0. LCM(a, b) = (a × b) ÷ GCD(a, b). For three or more numbers, the result accumulates pairwise in order.
| Input | GCD | LCM |
|---|---|---|
| 12, 18 | 6 | 36 |
| 12, 18, 24 | 6 | 72 |
Tiling a floor (GCD) and buses meeting up (LCM) — two everyday calculations
To tile a 360cm × 240cm room completely with square tiles and no leftover scraps, the largest usable tile side must equal the greatest common divisor of the two lengths. GCD(360, 240)=120, so a 120cm tile gives 360÷120=3 tiles across and 240÷120=2 tiles down — 6 tiles total, with no gaps. Pick an arbitrary 100cm tile instead, and neither 360 nor 240 divides evenly by 100, leaving scrap pieces at the edges.
Bus schedules use the LCM the opposite way. If a Route A bus arrives every 12 minutes and a Route B bus every 18 minutes, and both depart together at 9:00 AM, they next depart together after the least common multiple of the two intervals. LCM(12, 18)=36, so they meet again 36 minutes later, at 9:36 AM. Tiling finds the "largest shared unit that still fits" (GCD), while bus schedules find the "shared cycle where both realign" (LCM) — opposite uses of the same pair of integers.
The Euclidean algorithm in one line
The Euclidean algorithm repeatedly replaces the larger number with the remainder of dividing it by the smaller, until the remainder reaches 0. For GCD(48, 18): 48 mod 18 = 12 → continue with (18, 12); 18 mod 12 = 6 → continue with (12, 6); 12 mod 6 = 0, so the last nonzero remainder, 6, is the GCD. This calculator uses the exact same method internally, finding the GCD of even very large numbers in just a few steps.