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
- Up to 100 integers, 1,000 digits per integer and 20,000 characters for the whole list.
- Use no thousands separators.
- Decimals and fractions are refused.
- The LCM is checked before multiplication using an estimated digit count; an estimate above 5,000 digits is refused conservatively.
- Negative inputs use their absolute values.
More details
A zero anywhere makes the LCM zero;
GCD(0, 0) is zero by convention.
Euclidean steps are available for exactly two inputs.
This produces a numeric working list, not a prime-factor tree.
Where your input is processed
This tool does not upload your inputs. See the limits for anything saved 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
BigInt keeps integer operations exact beyond JavaScript’s ordinary safe-integer range. Each input can have up to 1,000 digits, within the whole-list character limit. Before forming the next LCM product, the tool estimates its size and refuses an estimate above 5,000 digits. That conservative check limits oversized output; it is not an exact prediction of the final digit count.
Questions about GCD and LCM Calculator
What is the difference between the GCD and the LCM?
For nonzero integers, the GCD (also called HCF) is the greatest positive integer dividing every entry; the LCM is the least positive multiple shared by them. For 18 and 24 they are 6 and 72. Zero inputs use the conventions explained below.
Why does a zero make the LCM zero?
For nonzero inputs the usual LCM is the least positive common multiple. When any input is zero, this tool follows the convention LCM(0, n) = 0 and states that in 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. Enter whole numbers only. To simplify a fraction or turn 0.5 into 1/2, use Fraction Calculator instead.