GCF and LCM Calculator: Greatest Common Factor and Prime Factors

GCF and LCM Calculator

Find the greatest common factor (GCF/GCD), least common multiple (LCM), and prime factorization of one or more integers.

Separate 1–20 integers with commas, spaces, semicolons or new lines. Negative signs are accepted and magnitudes are used. Maximum magnitude: 1,000,000,000,000.


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

InputsGCFLCMPrime-factor check
12, 1863612=2²×3; 18=2×3²
8, 12, 204120Shared factor 2²
21, 634221=3×7; 6=2×3
13, 171221Both are prime
48, 1801272048=2⁴×3; 180=2²×3²×5
0, 12120Factorization of 0 is undefined
1, 1111 has no prime factors
−24, 361272Uses integer magnitudes

How to use the calculator

  1. Enter one or more whole numbers.
  2. Separate them with commas, spaces, semicolons or new lines.
  3. Select Calculate GCF and LCM.
  4. 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.