How to use GCD and LCM Calculator
- Type the integers into Integers, separated by commas, spaces or line breaks.
- Tick Show the Euclidean steps for two integers if you want the divisions written out.
- Both results update as you change the integers.
- Read both results and, for two integers, the line linking the LCM to the product.
Example: GCD and LCM Calculator
GCD and LCM of 18 and 24, with the Euclidean steps shown.
Options
- Show the Euclidean steps
- Available when exactly two integers are entered, because only then is each division short enough to follow. Longer lists return the results without steps.
- Integers
- Whole numbers only, positive or negative. A minus sign is allowed and both results are computed from absolute values.
Supported inputs and limits
Where your input is processed
This tool processes your input in this browser. Your text and files are not uploaded to UseFreeTools. Check this tool's limits for anything it may save on your device.
One trace of Euclid's algorithm
Dividing 24 by 18 leaves a remainder of 6, and dividing 18 by 6 leaves no remainder, so 6 is the greatest common divisor. Steps are shown for two integers because each line maps to one division you can check. The least common multiple follows from the same pair: the product divided by the GCD gives (24 / 6) * 18 = 72.
Exact arithmetic past the safe range
The arithmetic runs on BigInt rather than floating point, so long integers are handled without the rounding that appears once numbers pass the safe range for ordinary JavaScript numbers. That allows 1,000 digits per entry, and it is why the tool can say in advance that a least common multiple would grow past 5,000 digits.
Questions about GCD and LCM Calculator
What is the difference between the GCD and the LCM?
The GCD is the largest whole number that divides every entry, and the LCM is the smallest number every entry divides. For 18 and 24 they are 6 and 72.
Why does a zero make the LCM zero?
Zero is a multiple of every number, so it is the smallest multiple a zero and any other number share. The tool prints that convention beside the result.
Can I enter negative integers?
Yes. -12 and -18 give a GCD of 6 and an LCM of 36, because both results use absolute values and the page says the sign was ignored.
Do decimals or fractions work as input?
No. Entries have to be whole numbers. Write 0.5 as 1 and 2, then simplify that with the Ratio and Proportion Calculator.