NumberSwift.
MATH · FRACTIONS

GCD & LCM Calculator

Find the greatest common divisor and least common multiple of two or more exact integers.

YOUR NUMBERS

Enter 2–50 integers, each up to 100 digits. Negative values use their absolute magnitude. Commas separate numbers, not thousands.

◎ Calculations stay in your browser.

A LITTLE CLARITY

Greatest common divisor (GCD / HCF)

6
Least common multiple (LCM)180
Integers included3

2–50 integers, each at most 100 digits; exact output limited to 2,000 digits. Negative signs do not change divisor or multiple magnitudes. An all-zero list has no positive GCD and is rejected.

Formula checked · NumberSwift · Review process

BEHIND THE NUMBERS

How this calculator works

The GCD is the largest positive integer dividing every entered value. The LCM is the smallest nonnegative common multiple, using the convention that a list containing zero has LCM zero. The Euclidean algorithm repeatedly takes remainders to find the GCD. Pairwise LCM uses division by GCD before multiplication, and BigInt keeps the calculation exact beyond ordinary safe-number limits. For fractions, the GCD reduces terms and the LCM helps find a shared denominator.

Formula

gcd(a,b) = gcd(b, a mod b), ending when b=0. lcm(a,b) = |a/gcd(a,b) × b| for nonzero a,b. Fold each operation across the input list.

Assumptions & limitations

2–50 integers, each at most 100 digits; exact output limited to 2,000 digits. Negative signs do not change divisor or multiple magnitudes. An all-zero list has no positive GCD and is rejected.

Worked example

For 12, 18 and 30, the greatest common divisor is 6. lcm(12,18)=36 and lcm(36,30)=180, so the least common multiple of the whole list is 180.

Our approach to calculations ↗
GOOD TO KNOW

Common questions

Are GCD and HCF different?

No. Greatest common divisor and highest common factor name the same positive integer.

What happens if one value is zero?

The GCD uses the other nonzero values; the LCM is zero under the stated convention. An all-zero list is rejected because it has no largest positive common divisor.

Can I enter integers larger than JavaScript’s safe-number range?

Yes. Decimal integer strings are parsed directly as BigInt, with clear input-digit and result-digit limits.