GCD / LCM Calculator: Find the Greatest Common Divisor and Least Common Multiple of Any Whole Numbers
An lcm and gcd calculator takes two or more whole numbers and returns the two numbers that tie them together: the greatest common divisor, the largest whole number that divides every one of them evenly, and the least common multiple, the smallest whole number that every one of them divides into evenly. Type the numbers in, separated by commas or spaces, and you get both answers at once, plus the working.
The two answers form a natural pair. The GCD is the biggest piece quantities share, used when you simplify a fraction. The LCM is the first point where repeating cycles line up, used when you add fractions with unlike denominators or work out when two schedules meet.
How the calculator works
For 12 and 18, the GCD is 6 and the LCM is 36. Two bounds give a quick sanity check: the GCD never exceeds the smallest number entered, and the LCM never falls below the largest.
For the GCD, the calculator uses Euclid's algorithm, a method over two thousand years old. It rests on one observation: the GCD of two numbers equals the GCD of the smaller number and the remainder from dividing the larger by the smaller. Repeat, swapping in the remainder each time, until a remainder hits zero; the last nonzero remainder is the GCD. No factoring is involved, so it stays fast even for very large numbers.
For the LCM, the calculator uses the GCD it just found. For two numbers a and b, the LCM equals a times b divided by their GCD. Multiplying gives a common multiple; dividing by the GCD strips out the part counted twice. With three or more numbers, the calculator folds the same pair operation across the list. All arithmetic runs on exact big integers, so answers are exact, with no rounding.
Every input, explained
Integers, separated by commas or spaces. This is the only field, and it takes 2 to 10 whole numbers. Type them like "48, 180" or "12 18 24"; commas, spaces, and semicolons all work. Sorting is unnecessary, and duplicates change nothing.
Negative numbers and zero. Negatives are accepted, and the calculator works with their absolute values, because divisibility doesn't care about sign: -48 has exactly the same divisors as 48. Zero follows its own rules, covered below. What gets rejected. Decimals are rejected, since GCD and LCM are defined for integers, not numbers like 4.5. A single number, an all-zero input, or more than 10 numbers are also rejected.
The results. Press Calculate and you get the GCD and LCM, the Euclid steps, and a two-number check line.
A worked example: 48 and 180
Take 48 and 180. Euclid's algorithm divides the larger by the smaller, then repeats with divisor and remainder until the remainder is zero. 180 = 3 x 48 + 36. Next, 48 = 1 x 36 + 12. Then 36 = 3 x 12 + 0. The remainder is zero, so the algorithm stops, and the last nonzero remainder is the GCD: 12.
The LCM follows in one line: 48 x 180 = 8,640, divided by 12 = 720. The check confirms it: 12 x 720 = 8,640 = 48 x 180.
The prime factor method reaches the same answers from a different direction. 48 = 2^4 x 3, and 180 = 2^2 x 3^2 x 5. The GCD takes the lowest power of each shared prime: 2^2 x 3 = 12. The LCM takes the highest power of every prime in either number: 2^4 x 3^2 x 5 = 720. Euclid is faster for large numbers, but the factor view shows why the answers are what they are.
GCD and LCM for common pairs
| Numbers | GCD | LCM |
|---|---|---|
| 12 and 18 | 6 | 36 |
| 24 and 36 | 12 | 72 |
| 100 and 80 | 20 | 400 |
| 48 and 180 | 12 | 720 |
In every row, GCD times LCM equals the product of the pair: 6 x 36 = 216 = 12 x 18, and 20 x 400 = 8,000 = 100 x 80.
A second example: 12, 18, and 24
With three numbers, the calculator folds the pair operations one stage at a time: gcd(12, 18) = 6, then gcd(6, 24) = 6, so the GCD is 6; lcm(12, 18) = 36, then lcm(36, 24) = 72, so the LCM is 72. The factor view agrees: 2 x 3 = 6 and 2^3 x 3^2 = 72. One warning: the pair identity does not extend to three numbers, since 12 x 18 x 24 = 5,184 but GCD times LCM is 432.
Zero, negatives, and edge cases
Zero has its own rules. Every integer divides zero, so gcd(0, 18) = 18. The LCM runs the other way: the only multiple shared by 0 and anything else is 0, so an LCM that includes zero is 0. An all-zero input is the one case with no answer, and the calculator says so plainly. Coprime pairs are another edge: sharing no prime factor, gcd(8, 15) = 1 and lcm(8, 15) = 120. When one number divides the other, the answers are trivial: gcd(12, 36) = 12 and lcm(12, 36) = 36.
Where GCD and LCM turn up in real life
Fractions are the most common meeting point. Simplifying means dividing top and bottom by their GCD: 48/180 divided by 12 gives 4/15. Adding runs the other way: to add 1/12 and 1/18, the LCM, 36, is the smallest workable denominator, giving 3/36 + 2/36 = 5/36.
Scheduling is the second home of the LCM: if buses leave every 12 and 18 minutes, and both leave together at noon, they next leave together 36 minutes later. Tiling belongs to the GCD: the largest square tile covering a 48 by 180 floor with no cutting is 12 by 12, taking 4 tiles one way and 15 the other.
Common mistakes
- Answering with the wrong one of the pair. A question about when cycles next coincide wants the LCM; a question about the largest equal share wants the GCD.
- Forgetting to divide by the GCD when finding the LCM. 48 x 180 = 8,640 is a common multiple, but only dividing by 12 turns it into the least one, 720.
- Entering decimals. GCD and LCM are defined for whole numbers, so 4.5 is rejected. Scale decimals to integers first, then scale back.
- Extending the pair identity to three numbers. GCD times LCM equals the product for two numbers only; for 12, 18, and 24 it gives 432, not 5,184.
- Stopping at the first common multiple you meet. A hasty list can land on 144 instead of 72 for some pairs. Euclid plus the GCD division removes the guesswork.
Practical tips
Simplify fractions before you multiply them: dividing by the GCD early keeps later numbers small. When you add fractions, use the LCM as the denominator rather than the product, which always works but forces a simplification pass at the end. Use the check line as a habit: for any pair, GCD times LCM must equal the product.
Frequently asked questions
What are the GCD and LCM of 48 and 180?
The GCD is 12 and the LCM is 720. Euclid's steps are 180 = 3 x 48 + 36, 48 = 1 x 36 + 12, 36 = 3 x 12 + 0, and 48 x 180 / 12 = 720.
Can I enter negative numbers or zero in the GCD and LCM calculator?
Yes. Negatives convert to absolute values. Zero follows the standard rules: gcd(0, n) = n, and any LCM including zero is 0. Only all-zero input is rejected.
What is the difference between GCD and LCM?
The GCD is the largest number dividing all your numbers evenly, so it never exceeds the smallest entered. The LCM is the smallest number they all divide into evenly, so it never falls below the largest entered.
Why does the calculator show Euclid's algorithm steps?
So you can follow the answer instead of taking it on trust. Each step is one division with remainder, ending when a remainder hits zero and the previous remainder is the GCD.
Does GCD times LCM always equal the product of the numbers?
Only for two numbers, where GCD x LCM = a x b always holds. For three or more it fails: 12, 18, and 24 give 432 against a product of 5,184.
Related calculators: the Macro Calculator for splitting daily calories, the Period Calculator for tracking cycle dates, and the Dice Roller for rolling dice with a fair random result.
The GCD and LCM are the two quickest ways to pull structure out of a pair of numbers: the biggest piece they share, and the first moment their cycles meet. Next time a fraction needs simplifying or a schedule needs syncing, run the pair through this calculator and check the Euclid steps against your own working. More maths guides live on the CalcMega Blog.
Disclaimer: this guide teaches GCD and LCM arithmetic for learning and everyday use, and its worked examples were checked by independent calculation. It is not a substitute for a maths textbook or a teacher's instruction, so if an answer here disagrees with your coursework, follow your course's method and use the step display to find where the two paths diverge.
Further reading: Khan Academy's practice pages on greatest common factors and least common multiples cover the same ideas with extra exercises, on its GCF and LCM topic page.