Math calculator

GCF & LCM Calculator

Find the GCF (GCD), LCM, and prime factorization of two or more integers.

Enter at least two positive whole numbers within JavaScript’s safe integer range.

Greatest common factor

—

What it needs and what it returns

Enter two or more positive whole numbers, separated by commas, spaces, or new lines. Every entry has to be a positive integer within JavaScript's safe integer range (up to 2^53 − 1); a decimal, a negative number, or zero anywhere in the list blocks the whole calculation rather than being skipped.

The output leads with the greatest common factor, then lists the least common multiple, then shows the prime factorization of every number you entered individually — useful for seeing exactly which shared factors produced the GCF.

If the true least common multiple would exceed that safe integer ceiling — which happens with large or mutually prime inputs — the LCM field reports "Too large" instead of an incorrect rounded number.

How both figures are built from prime factors

GCF = product of shared prime factors
LCM(a, b) = |a × b| ÷ GCF(a, b)

For 24 and 36: 24 breaks down into 2 × 2 × 2 × 3, and 36 breaks down into 2 × 2 × 3 × 3. The shared factors are two 2s and one 3, so GCF = 2 × 2 × 3 = 12. The least common multiple follows from the shortcut formula: LCM = (24 × 36) ÷ 12 = 864 ÷ 12 = 72.

With three or more numbers, the calculator finds the answer pairwise instead of all at once: it computes the GCF (or LCM) of the first two numbers, then combines that result with the third number, and so on. For 4, 6, and 8, that means GCF(4, 6) = 2, then GCF(2, 8) = 2, giving a final GCF of 2.

The shortcut formula only works for two numbers

GCF × LCM = the product of the two original numbers, but only when there are exactly two numbers involved. That identity breaks down for three or more, and mistaking it for a general rule is the most common error with this tool.

Take 4, 6, and 8. The GCF is 2, and working through the pairwise LCM gives 24 — bus-schedule style, the smallest number divisible by all three. Multiplying GCF × LCM gives 2 × 24 = 48. But the product of the three original numbers is 4 × 6 × 8 = 192, nowhere close to 48. The two-number shortcut simply has no three-number equivalent; the calculator always works it out from prime factors instead.

Where GCF and LCM actually get used

These two figures solve two different kinds of everyday problem — grouping evenly and finding a shared cycle:

  • Simplifying fractions – dividing 24/36 by their GCF of 12 reduces it to 2/3 in one step
  • Recurring schedules – if bus A comes every 24 minutes and bus B every 36 minutes, both arrive together every LCM(24, 36) = 72 minutes
  • Splitting into equal groups – 36 students and 24 pencils split into the largest equal groups using their GCF of 12, giving 12 groups of 3 students and 2 pencils each
  • Packaging quantities – hot dogs sold in packs of 8 and buns sold in packs of 12 first come out even at LCM(8, 12) = 24, meaning 3 packs of hot dogs and 2 packs of buns
  • Music and rhythm – two drum patterns repeating every 4 and 6 beats realign every LCM(4, 6) = 12 beats
  • Tiling and layout – tiles measuring 18 cm and 24 cm across both fit evenly into a run measuring their LCM, 72 cm

Frequently asked questions

What's the actual difference between GCF and LCM?

GCF is the largest number that divides evenly into every input — useful for splitting things into equal groups or simplifying fractions. LCM is the smallest number that every input divides evenly into — useful for finding when repeating cycles line up.

Does GCF times LCM always equal the product of the numbers?

Only with exactly two numbers. For 24 and 36, GCF (12) × LCM (72) = 864, which does match 24 × 36. But for 4, 6, and 8, GCF (2) × LCM (24) = 48, while 4 × 6 × 8 = 192 — the identity doesn't extend to three or more inputs.

Why does the calculator require positive whole numbers only?

Both GCF and LCM are defined in terms of integer factors, so decimals don't have a meaningful prime factorization. The tool also caps inputs at JavaScript's safe integer limit to avoid silently rounding a result that's too large to represent exactly.

Why does my LCM show "Too large" instead of a number?

This appears when the true least common multiple would exceed 2^53 − 1 (about 9.007 quadrillion), which happens fastest with large inputs that share few or no common factors, since their LCM is close to their full product.

How does GCF simplify a fraction?

Divide the numerator and denominator by their GCF. For 24/36, the GCF is 12, so dividing both by 12 gives 2/3 — the simplest form of the same fraction.

What happens when two numbers share no common factor besides 1?

They're called coprime, and their GCF is always 1. Their LCM then equals the plain product of the two numbers — for 7 and 10, GCF is 1 and LCM is 7 × 10 = 70.