How to use the GCD and LCM calculator
- 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.
- Choose Calculate or press Enter. Negative inputs are converted to absolute values for the calculation, while zero follows the explicit rules described below.
- 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.
- 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
- Use the GCD to reduce a fraction or ratio by dividing every term by the same largest common factor.
- Use the LCM to find a common denominator or determine when repeating schedules with integer periods align again.
- Check whether a collection is collectively coprime before a number-theory exercise. This does not claim that every pair in the set is coprime.
- Compare classroom work based on prime factors with the exact Euclidean-algorithm result. The page does not expose a factor-list or prime-factorization mode.
Input limits and error help
- Enter 2 to 20 integers. Each value must be between −1,000,000,000,000 and 1,000,000,000,000 inclusive.
- Decimals, fractions, and scientific notation are not integers in this input format. Use a leading minus sign for negatives and plain uninterrupted digits.
- Zero is accepted. A mixed list uses gcd(a,0)=|a| and has LCM 0; an all-zero list shows an undefined GCD and LCM 0.
- All calculations use exact integers. The LCM output is limited to 300 digits; with the published count and per-value limits, ordinary accepted inputs remain below that ceiling.
- Collectively coprime means one GCD across the entire list equals 1. It is weaker than pairwise coprime; for example 6, 10, 15 are collectively but not pairwise coprime.
- This calculator does not list divisors, factor numbers, analyze additional integer properties, or accept an unbounded stream of values.
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.