GCD and LCM Calculator
Find the greatest common divisor (GCD) and least common multiple (LCM) of several integers using the Euclidean algorithm, with a step table and coprime check.
Last updated:
Input
Enter integers separated by commas to compute the greatest common divisor (GCD) and least common multiple (LCM). Spaces and new lines also work as separators.
Example: 12, 18, 24
Result
Greatest common divisor (GCD)
6
Least common multiple (LCM)
72
Number of inputs
3
Coprime
No
Input integers (absolute value)
Euclidean algorithm steps
For the first two numbers, division is repeated until the remainder reaches 0.
| Dividend | Divisor | Quotient | Remainder |
|---|---|---|---|
| 18 | 12 | 1 | 6 |
| 12 | 6 | 2 | 0 |
The GCD is found with the Euclidean algorithm, and the LCM is the product divided by the GCD. Signs are ignored and absolute values are used.
How it works
- The greatest common divisor (GCD) is the largest positive integer that divides every input, found by applying the Euclidean algorithm from left to right.
- The least common multiple (LCM) is the smallest positive common multiple of all inputs, computed pairwise as the product divided by the greatest common divisor.
- Signs are ignored and absolute values are used. When any input is zero, the least common multiple is treated as zero.
- When the greatest common divisor equals 1, the integers are coprime.
- If the least common multiple exceeds the safe integer range, it is reported as an overflow.
Frequently asked questions
- How are the GCD and LCM calculated?
- The GCD is found by applying the Euclidean algorithm from left to right, and the LCM is built pair by pair as product ÷ GCD.
- What is the relationship between GCD and LCM?
- For two numbers, GCD × LCM equals the product of the two numbers. For 12 and 18 the GCD is 6 and the LCM is 36, so 6 × 36 = 216 = 12 × 18.
- What happens with negative numbers or zero?
- Signs are ignored and absolute values are used. If any input is 0 the LCM is treated as 0, and when the GCD is 1 the integers are coprime.
Reviews
Tell us what you think of this calculator.
Write a review
Rating