LCM & GCF Calculator

GCF & LCM
GCF 6 · LCM 180
 

1Your Numbers

Separate with commas, spaces, or new lines — up to 20 numbers, each 1,000,000,000 or smaller.

Breakdown

GCF (greatest common factor)6
LCM (least common multiple)180
Works with positive whole numbers up to 1,000,000,000 and up to 20 numbers per list, so every result stays exact. The GCF takes the lowest power of each shared prime; the LCM takes the highest power of every prime that appears.

What Is an LCM & GCF Calculator?

The greatest common factor (GCF) and least common multiple (LCM) are the two workhorses of whole-number arithmetic: the GCF is the largest number that divides evenly into every number in your list, while the LCM is the smallest number that every one of them divides into. An LCM & GCF calculator finds both at once for a list of two or more positive integers. The CalcFinity version accepts up to 20 numbers, recalculates live as you type, and also shows the prime factorization of each number so you can see exactly why the answers are what they are.

How It Works

Rather than listing out factors and multiples the way it’s taught in school, the calculator uses Euclid’s algorithm — a method over two thousand years old and still the fastest known. To find the GCF of two numbers, repeatedly replace the larger with the remainder of dividing it by the smaller; when the remainder hits zero, the last non-zero remainder is the GCF. Longer lists are folded pairwise: GCF(a, b, c) = GCF(GCF(a, b), c).

Euclid’s algorithm

Repeat until the second value reaches zero:

GCF(a, b) = GCF(b, a mod b)

The LCM from the GCF

The LCM comes free once the GCF is known:

LCM(a, b) = (a ÷ GCF(a, b)) × b

This works thanks to the identity a × b = GCF(a, b) × LCM(a, b). The calculator computes each pairwise LCM as (a ÷ GCF) × b — dividing first to keep intermediate numbers small — and folds that across the list the same way. Prime factorizations offer another view: the GCF takes the lowest power of each shared prime, while the LCM takes the highest power of every prime that appears anywhere. To keep results exact in JavaScript’s safe-integer range, inputs are capped at 1,000,000,000 each and 20 numbers per list.

Worked Example: 12, 18, 30

Enter 12, 18, 30 — the calculator’s default input. Euclid on 12 and 18: 18 mod 12 = 6, then 12 mod 6 = 0, so GCF(12, 18) = 6; then GCF(6, 30) = 6. So the GCF is 6. For the LCM: LCM(12, 18) = (12 ÷ 6) × 18 = 36, then LCM(36, 30) = (36 ÷ 6) × 30 = 180, giving an LCM of 180.

The prime factorizations in the breakdown confirm it: 12 = 2² × 3, 18 = 2 × 3², 30 = 2 × 3 × 5. Lowest shared powers: 2 × 3 = 6. Highest powers of everything: 2² × 3² × 5 = 180.

Why LCM and GCF Matter

The LCM is the key to adding fractions: to compute 1/12 + 1/18, you need the least common denominator, which is exactly LCM(12, 18) = 36. It also solves scheduling puzzles — if one bus arrives every 12 minutes and another every 18, they pull in together every 36 minutes.

The GCF goes the other direction: it simplifies fractions, splits collections into the largest possible equal groups, and finds the biggest square tile that covers a rectangular floor without cutting.

Common Mistakes to Avoid

The most common mix-up is grabbing the wrong tool: students often compute the GCF when a problem needs the LCM, or vice versa. A reliable sanity check is that the GCF can never be larger than your smallest number, and the LCM can never be smaller than your largest — if your “GCF” of 12 and 18 came out as 36, you actually found the LCM. Direction matters in word problems too: questions about splitting, sharing, or the biggest equal group point to the GCF, while questions about events lining up, repeating cycles, or common denominators point to the LCM.

Another frequent error is assuming the LCM is always the product of the numbers. That shortcut only works when the numbers are coprime: LCM(8, 15) really is 120, but LCM(12, 18) is 36, not 216, because 12 and 18 share the factor 6 and multiplying them double-counts it. When working by prime factorization, remember the GCF takes only the primes the numbers share (at their lowest powers), while the LCM must include every prime that appears in any number (at its highest power) — dropping the 5 from 30 in the example above would wrongly shrink the LCM from 180 to 36.

Frequently Asked Questions

What’s the difference between GCF, GCD, and HCF?

Nothing — they are three names for the same thing. Greatest common factor, greatest common divisor, and highest common factor all mean the largest whole number that divides every number in the list exactly.

Why does the calculator limit inputs to 1 billion and 20 numbers?

JavaScript stores numbers with 53 bits of integer precision, and an LCM of many large values can exceed that, producing silently wrong results. The caps keep every computation exact. If the LCM itself would overflow, the calculator reports an error instead of guessing.

Can the GCF of two numbers be 1?

Yes — numbers that share no factor except 1, like 8 and 15, are called coprime or relatively prime. When numbers are coprime, their LCM is simply their product: LCM(8, 15) = 120.

How is the prime factorization found?

By trial division: the calculator divides each number by 2 as many times as possible, then by 3, 5, 7, and so on up to the number’s square root. Whatever remains greater than 1 at the end is itself a prime factor.

Scroll to Top