GCD & LCM Calculator
Find the greatest common divisor (GCD) and least common multiple (LCM) of two or more whole numbers, with the full step-by-step working shown.
- Free, no account
- No watermark
- No usage limit
About the GCD & LCM Calculator
Type in two or more whole numbers and you get both the GCD and the LCM at once, with the actual working spelled out underneath. That working is the whole reason this exists. Plenty of calculators hand you the answer, GCD(12, 18) is 6, LCM(4, 6) is 12, and stop there, which is fine right up until your homework says "show your work" and you're staring at a blank line. This one prints Euclid's algorithm step by step, the same division-and-remainder lines you'd copy onto the page. Nothing you type gets uploaded, it all runs in your browser.
It does the greatest common divisor and the least common multiple together, off the same computation, so you're not running two separate tools and shuttling numbers between them. Give it a whole list and it folds the result across everything you typed, GCD(12, 18, 24) is 6, LCM(4, 6, 8) is 24. There's no button either, the answers move the instant you change a number.
How to use
- Type your numbers. Two or more whole numbers in the box, split by commas or spaces, like
12, 18, 24or4 6 8. - Read the two answers. GCD and LCM sit side by side and update live.
- Check the working. The GCD box walks through Euclid's algorithm line by line. The LCM box shows how it falls out of the GCD.
- Change anything. Add a fourth number, drop one, throw in a negative, and watch the result update.
Negatives are allowed, the sign just gets ignored, since GCD and LCM only care about size. Decimals and fractions don't work because these ideas are only defined for whole numbers, and the tool says so politely instead of rounding behind your back. You do need at least two numbers. One number has nothing to share a factor with.
The working is the actual feature
Finding a GCD by listing every divisor and comparing is fine for small numbers and miserable for anything bigger. Euclid worked out the shortcut around 300 BC and it's still what every calculator runs, because it's quick and it never guesses. The idea fits in a sentence: the GCD of two numbers equals the GCD of the smaller one and the remainder after you divide. Swap the pair for (smaller, remainder) and repeat until the remainder is zero. The last non-zero number is your answer.
Here it is on 12 and 18:
- 18 ÷ 12 = 1 remainder 6, so now you're finding GCD(12, 6).
- 12 ÷ 6 = 2 remainder 0.
- The remainder hit zero, and the last non-zero number was 6. So GCD(12, 18) = 6.
Now a pair where listing divisors would ruin your afternoon, 1071 and 462:
- 1071 ÷ 462 = 2 remainder 147.
- 462 ÷ 147 = 3 remainder 21.
- 147 ÷ 21 = 7 remainder 0, which makes the GCD 21.
That's three lines and no factoring at all. The tool prints exactly these lines for whatever you enter, which is the part an answer-only calculator can't give you. Copy them straight into your notebook, or use them to check the work you already did on paper.
What GCD and LCM actually mean
A divisor of a number is any whole number that goes into it evenly. The divisors of 12 are 1, 2, 3, 4, 6, 12. The divisors of 18 are 1, 2, 3, 6, 9, 18. The ones both lists share are 1, 2, 3, and 6, and the biggest of those, 6, is the greatest common divisor.
A multiple is what you get counting up by a number: 4, 8, 12, 16 and so on. Line up the multiples of 4 against the multiples of 6, and the smallest number sitting on both lists is 12, the least common multiple. So the GCD is the biggest factor your numbers all share. The LCM flips that around, it's the first number every one of them divides into.
The naming is what actually confuses people. There are three names in circulation for one single number: GCD, plus GCF for greatest common factor, plus HCF for highest common factor. US classes tend to write GCF, UK ones write HCF, programmers say GCD, and older books toss in GCM or HCD. You get the same answer every time, so don't second-guess yourself when the worksheet uses a different set of letters than the calculator does.
Big numbers stay exact
This is where a lot of quick free calculators quietly fall down. Once a number climbs past about 15 or 16 digits, anything running on ordinary floating-point math starts handing back a wrong last digit, and it won't warn you it did. This one uses exact integer arithmetic the whole way through, so you can paste in a 40-digit number and the GCD and LCM come back correct to the last place. Euclid's algorithm keeps it fast even then, since every step chops the numbers down in size.
Where it comes up
The everyday one is fractions. To reduce a fraction, divide the top and bottom by their GCD. 18/24 has a GCD of 6, so it drops straight to 3/4 in one step. To add fractions you want the least common denominator, which is nothing more than the LCM of the denominators. That's the same math our fraction calculator leans on.
The other place it turns up is anything with two cycles that need to line back up. Two buses pull out of the depot together, then run every 12 and every 18 minutes, and the next time they leave side by side is LCM(12, 18) = 36 minutes later. Gear teeth, traffic lights, shift rotations, overlapping schedules, they're all the same LCM question underneath.
Frequently asked questions
Do negatives and zeros work?
Negatives are fine, the tool strips the sign, so -12 and 12 give the same GCD and LCM. A zero is the case worth knowing: every whole number divides 0 evenly, so GCD(0, 8) comes out as 8, but 0 shares no positive multiple with anything, so the LCM is reported as 0 and the tool tells you why instead of showing something misleading.
Why won't it accept a decimal or fraction?
Because GCD and LCM are only defined for whole numbers. There is no "greatest common divisor" of 2.5 and 3.75 in the usual sense. Rather than silently round your input and answer a different question, the tool flags the bad value and asks for integers. If you are working with fractions, reduce or combine them first, and the whole numbers that fall out are fair game.
Can it handle three or more numbers?
Yes, type as many as you like. It works two at a time, the GCD of the first pair, then the GCD of that result with the next number, and onward, and the same folding trick handles the LCM. One caution: the tidy rule that GCD times LCM equals the product only holds for exactly two numbers, so don't expect it to check out on a longer list.
Why does the LCM come out of the GCD?
For two numbers, LCM(a, b) = (a × b) ÷ GCD(a, b). Once Euclid's algorithm has handed over the GCD, the LCM is one multiply and one divide away, with no separate factoring needed. That is why the tool can show both without doing the work twice, and why the LCM box refers back to the GCD it just found.
My teacher wants the steps shown. Which method is this?
The GCD steps use Euclid's algorithm, the division-and-remainder chain, which is what most courses expect once you're past the basics. If your class specifically teaches prime factorization instead (break each number into primes, take the shared primes at the lowest power for the GCD and every prime at the highest power for the LCM), the answer the tool gives is identical. You'll just be writing a different route to the same number.
Is there a size limit?
Not really. There's no cap on how many numbers you enter or how long each one is, which is where some free calculators quietly stop you, a field locked to 10 or 15 digits, or a limit of a few values at a time. Paste something genuinely huge, thousands of digits down a long list, and you'd feel the browser pause for a beat. For homework and real-world numbers, the answer is instant.
Does it work offline and stay private?
Both. Every calculation happens on your device, nothing you enter is sent anywhere or logged. Once the page has loaded you can drop your connection entirely and it keeps working, so a plane or a dead-signal basement is no problem.