Skip to content

GCD and LCM calculator

Find the greatest common divisor, least common multiple, and collective coprime status for 2 to 20 integers.

a, b, … → gcd / lcm

Enter your integers

Your data stays in this browser.

Separate 2 to 20 integers with commas, spaces, semicolons, or new lines. Each absolute value must be at most 1,000,000,000,000.

Exact integer results

Common divisor and multiple

Enter at least two integers and choose Calculate.

How to use the GCD and LCM calculator

  1. Enter between 2 and 20 whole integers in one line. Separate entries with spaces, commas, semicolons, or line breaks; do not use commas inside a number as thousands separators.
  2. Choose Calculate or press Enter. Negative inputs are converted to absolute values for the calculation, while zero follows the explicit rules described below.
  3. Read the exact GCD, exact LCM, and whether the whole set is collectively coprime. Collective coprimality means the GCD of all entered values is 1.
  4. Editing any input clears the old result immediately. Copy results exports the three result lines, and Clear removes input, results, errors, and copy status.

How GCD and LCM are calculated

The greatest common divisor gcd(a,b) is the largest positive integer that divides both values. Euclid’s algorithm repeatedly replaces (a,b) with (b, a mod b) until the second value is zero.

For nonzero values, lcm(a,b) = |a ÷ gcd(a,b) × b|. Dividing before multiplying keeps the intermediate exact integer smaller. For more than two values, the calculator reduces the list one pair at a time.

Signs do not affect divisibility, so gcd(−a,b) = gcd(a,b) and the LCM is nonnegative. gcd(a,0) = |a| for nonzero a. gcd(0,0) is undefined. Any list containing zero has LCM 0.

Worked examples

Schedule cycles: 24, 36, and 60

Enter 24, 36, 60. Their GCD is 12 because 12 divides all three and no larger positive integer does. Their LCM is 360, the smallest positive value divisible by every input. Since the GCD is not 1, the set is not collectively coprime.

Negative values: −18 and 30

The signs are ignored for divisibility, so the calculator uses 18 and 30. Euclid’s algorithm gives GCD 6, and |−18 × 30| ÷ 6 gives LCM 90. Results are reported as nonnegative integers.

Zeros: 0 and 15 versus 0 and 0

For 0 and 15, the GCD is 15 and the LCM is 0. For 0 and 0, there is no greatest positive common divisor, so GCD is Undefined; the calculator uses the conventional LCM value 0 and reports the set as not coprime.

When to use these results

Input limits and error help

Frequently asked questions

Are GCD, GCF, and HCF the same?

In this context, yes. Greatest common divisor, greatest common factor, and highest common factor name the same largest positive integer that divides every input.

What happens with negative integers?

The calculator uses absolute values because changing a sign does not change positive divisors or multiples. The reported GCD and LCM are therefore nonnegative.

Why is gcd(0,0) undefined?

Every positive integer divides zero, so there is no greatest positive integer that divides both zeros. For one nonzero value a, gcd(a,0)=|a|.

Can the LCM be zero?

Yes. By the convention used here, the LCM is zero whenever any input is zero. This keeps lcm(a,0)=0 and works naturally in repeated pairwise calculation.

Does GCD 1 mean every pair is coprime?

No. It only means all values share no common factor above 1. The set 6, 10, 15 has overall GCD 1, although each pair shares a factor.