GCD and LCM
Find the greatest common divisor and least common multiple of two integers.
About this tool
The greatest common divisor uses the Euclidean algorithm on the absolute values. The least common multiple is the product of the absolute values divided by that divisor.
Signs do not change the divisor. Zero is handled as the rules above, not as an error.
How to use it
- Enter two whole numbers.
- Calculate.
- Read the greatest common divisor and the least common multiple.
Limitations
- The inputs are integers. A decimal is rejected.
- If either value is zero, the least common multiple is zero.
Euclidean gcd, then a product for lcm
Two whole numbers, two lines
Both inputs are integers, including negatives and zero, parsed without a decimal point. The greatest common divisor is computed with the Euclidean algorithm on the absolute values, so the printed gcd is never negative. The least common multiple is the absolute value of the first number, divided by that gcd, times the absolute value of the second. If either input is zero, the least common multiple is defined here as zero, which matches the idea that no positive common multiple exists in the usual sense and avoids dividing by a zero gcd.
Eighteen and forty-eight
gcd(48, 18): 48 leaves remainder 12 when divided by 18, 18 leaves 6 when divided by 12, and 12 divided by 6 leaves 0, so the gcd is 6. The lcm is 48/6 × 18 = 144. The panel prints those two lines, GCD then LCM. The pair −48 and 18 prints the same two figures, because signs are stripped before the loop. gcd(0, 15) is 15, and the lcm line is 0.
What is refused or quietly absolute
A decimal such as 4.5 is refused. A blank that is not a whole number is refused. The page does not list common divisors other than the greatest one, and it does not accept three integers at once. Pair them by running twice if you need a gcd of a longer list, remembering that gcd is associative. The prime-factorization page is a different route to the same ideas for a single integer greater than 1. It will not accept the zero that this page treats as a defined lcm of zero.
Using the pair twice
gcd and lcm are tied by the identity |a × b| = gcd(a, b) × lcm(a, b) when neither input is zero. For 48 and 18, 48 × 18 = 864 and 6 × 144 = 864. When one input is zero the lcm line is 0 and that product identity is the reason the page special-cases zero instead of dividing by the gcd. Three integers need two passes: gcd(gcd(a, b), c) and a similar nest for lcm, skipping a zero if your problem forbids it. Signs never appear on either printed line.
Privacy
Your input is processed in your browser and is not uploaded to UtilChain. File names, text, and results are not sent to analytics.

