GCD & LCM Calculator

Calculate GCD and LCM for two numbers or a list — runs entirely in your browser.

GCD
LCM


Greatest Common Divisor and Least Common Multiple

The Greatest Common Divisor (GCD), also called the Highest Common Factor (HCF), is the largest integer that divides all the given numbers without a remainder. The Least Common Multiple (LCM) is the smallest positive integer that is divisible by all the given numbers. This tool computes both simultaneously using the Euclidean algorithm for GCD and the identity LCM(a, b) = a / GCD(a, b) × b to avoid integer overflow. For lists of three or more numbers the algorithm is applied iteratively.

A common use case for GCD is simplifying fractions: divide numerator and denominator by their GCD to get the reduced form. LCM is used when adding fractions with different denominators — the LCM of the denominators gives the smallest common denominator. Everything runs locally in your browser with no server calls.

FAQ

What is GCD(0, n)? By convention, GCD(0, n) = n, because every integer divides 0. This tool follows that convention.

What happens if any number is 0 in the LCM? LCM returns 0 if any input is 0, since no positive multiple of 0 exists.

Can I enter more than two numbers? Yes. Switch to "List of numbers" and enter as many integers as needed, separated by commas or spaces.

Are negative numbers supported? Inputs are treated as their absolute values, since GCD and LCM are defined for positive integers.

Related tools

Popular tools