Skip to content

GCD & LCM Calculator

Greatest common divisor and least common multiple for any list of integers — both at once.

The greatest common divisor (GCD) and least common multiple (LCM) are two of the most useful operations in elementary number theory. The GCD is the largest integer that divides every number in your list with no remainder; the LCM is the smallest positive integer that every number in your list divides evenly. They turn up when reducing fractions, finding common denominators, scheduling repeating events, and factoring polynomials. Enter two or more whole numbers below and both values are computed instantly in your browser using Euclid's algorithm.

Enter two or more integers, separated by commas or spaces.

GCD (greatest common divisor)
6
LCM (least common multiple)
72

gcd(12, 18, 24) = 6 · lcm(12, 18, 24) = 72

How to use

  1. Type your integers

    Enter two or more whole numbers in the box, separated by commas or spaces — for example "12, 18, 24".

  2. Watch both results update

    The GCD and LCM are shown side by side and recompute as you type. There is no submit button.

  3. Read the answer

    The left box is the greatest common divisor; the right box is the least common multiple. The mono-spaced line underneath restates the calculation.

Worked examples

NumbersGCDLCM
12, 18636
17, 5185
4, 6212
12, 18, 24672
2, 3, 4112

Frequently asked questions

What is the greatest common divisor (GCD)?
The GCD of a set of integers is the largest positive integer that divides each of them with no remainder. For 12 and 18 it is 6, because 6 divides both and no larger number does. It is also called the greatest common factor (GCF) or highest common factor (HCF).
What is the least common multiple (LCM)?
The LCM of a set of integers is the smallest positive integer that is a multiple of every number in the set. For 4 and 6 it is 12, because 12 is the smallest number that both 4 and 6 divide evenly.
How are GCD and LCM related?
For any two integers a and b, gcd(a, b) × lcm(a, b) = |a × b|. So once you know the GCD you can get the LCM as |a × b| ÷ gcd(a, b) without listing multiples. This calculator uses exactly that identity.
What does it mean for numbers to be coprime?
Two integers are coprime (relatively prime) when their GCD is 1 — they share no common factor other than 1. 17 and 5 are coprime, so their GCD is 1 and their LCM is simply their product, 85.
How does Euclid's algorithm find the GCD?
Euclid's algorithm repeatedly replaces the larger number with the remainder of dividing it by the smaller one, until the remainder is zero. The last non-zero value is the GCD. It is far faster than factoring, especially for large numbers.
What happens with zero or a single number?
Following the standard convention, gcd(n, 0) = |n| and gcd(0, 0) = 0; the LCM is guarded to return 0 whenever one input is 0 so there is never a division by zero. You need at least two valid integers, otherwise the calculator shows a dash.

About

Why compute both together?

GCD and LCM are duals of one another and are almost always needed together — reducing a fraction uses the GCD, while adding fractions needs the LCM of the denominators. Showing both at once saves switching between two tools.

Integers only

GCD and LCM are defined on integers, so the calculator parses whole numbers and ignores anything that is not a valid integer. Signs are dropped because the divisibility relationships depend only on magnitude.

Sources & references

Authoritative references behind the math, constants, and tables on this page. Verified by Buğra Sözeri on the dates shown and re-checked at every deploy.