GCF and LCM Calculator
Find the greatest common factor (GCF/GCD), least common multiple (LCM), and prime factorization of one or more integers.
GCF, GCD and LCM formulas
The greatest common factor (also called greatest common divisor) is the largest positive integer that divides every input without a remainder. The calculator uses the Euclidean algorithm: repeatedly replace a pair (a, b) with (b, a mod b) until the remainder is zero.
For two nonzero integers, LCM(a,b) = |a × b| ÷ GCF(a,b). For more numbers, the GCF and LCM are applied one pair at a time.
Prime factorization writes an integer as a product of prime powers. The GCF uses the smallest exponent shared by every input; the LCM uses the largest exponent appearing in any input.
Checked examples
| Inputs | GCF | LCM | Prime-factor check |
|---|---|---|---|
| 12, 18 | 6 | 36 | 12=2²×3; 18=2×3² |
| 8, 12, 20 | 4 | 120 | Shared factor 2² |
| 21, 6 | 3 | 42 | 21=3×7; 6=2×3 |
| 13, 17 | 1 | 221 | Both are prime |
| 48, 180 | 12 | 720 | 48=2⁴×3; 180=2²×3²×5 |
| 0, 12 | 12 | 0 | Factorization of 0 is undefined |
| 1, 1 | 1 | 1 | 1 has no prime factors |
| −24, 36 | 12 | 72 | Uses integer magnitudes |
How to use the calculator
- Enter one or more whole numbers.
- Separate them with commas, spaces, semicolons or new lines.
- Select Calculate GCF and LCM.
- Review the common factor, common multiple and prime factorization of each magnitude.
When to use GCF or LCM
- GCF/GCD: simplify fractions or ratios, divide items into the largest equal groups, or find a shared measurement.
- LCM: find when repeating schedules coincide, create common denominators, or identify the smallest shared multiple.
- Prime factorization: expose the prime building blocks used to derive both GCF and LCM.
Limits and interpretation
- The calculator accepts 1–20 whole numbers with magnitudes no greater than one trillion.
- Negative inputs are converted to their absolute magnitudes because GCF and LCM are conventionally nonnegative.
- GCF(0,a)=|a| and LCM(0,a)=0 for nonzero a.
- If every input is zero, the GCF and prime factorization are undefined and the calculator rejects the set.
- A set is relatively prime when its group GCF is 1; this does not necessarily mean every pair is coprime.
- All GCF and LCM results use exact integer arithmetic.
Frequently asked questions
Are GCF, GCD and HCF the same?
Yes. Greatest common factor, greatest common divisor and highest common factor refer to the same positive integer.
Can the GCF be larger than the smallest input?
No, except that zero does not constrain the result. For positive inputs, the GCF cannot exceed the smallest number.
Why is the LCM zero when an input is zero?
Zero is a multiple of every integer, and the standard algebraic convention sets LCM(0,a)=0.
Does this replace the Ratio Calculator?
No. This tool analyzes factors and multiples of integer lists. The Ratio Calculator simplifies and scales ratios and compares proportions.
Related calculators
Use the Ratio Calculator to simplify proportions, the Fraction Calculator for exact arithmetic, or the Permutation and Combination Calculator for nPr and nCr.