Math & Education
LCM & GCF Calculator
Find the least common multiple (LCM) and greatest common factor (GCF/GCD) of two or more whole numbers, with their prime factorizations.
How to use
- 1Enter two or more whole numbers separated by commas.
- 2Read the GCF, LCM and each number's prime factors.
How it's calculated
GCF by Euclid's algorithm: gcd(a, b) = gcd(b, a mod b). LCM(a, b) = |a × b| ÷ gcd(a, b), applied across the list.
Frequently asked questions
What's the LCM used for?
Adding fractions (the least common denominator), and scheduling problems like 'when do two repeating events line up again'.
What's the GCF used for?
Simplifying fractions and splitting things into the largest equal groups.
Is GCF the same as GCD and HCF?
Yes — greatest common factor, greatest common divisor and highest common factor are the same thing.
GCF and LCM come from the same prime factorizations, read two ways
For 12, 18 and 30, the prime factorizations are 2²×3, 2×3², and 2×3×5. The GCF takes the lowest power of every prime that appears in all three — just 2¹×3¹ = 6, since 5 isn't in 12 or 18 at all. The LCM takes the highest power of every prime that appears in any of them — 2²×3²×5 = 180. Same three factorizations, opposite rule (lowest-shared vs. highest-anywhere), which is why this tool shows both results from one set of numbers.
Why LCM is the fraction trick you learned in school
Adding 1/12 and 1/18 needs a common denominator, and the smallest one that works is exactly the LCM: 180 from the example above, or more simply LCM(12, 18) = 36 if you only use those two. That's the real-world reason this calculator exists alongside a fraction calculator — finding the least common denominator by hand for anything beyond small numbers is slow, and using a denominator that isn't the LCM (just multiplying 12 × 18 = 216) still works but leaves a fraction that needs extra simplifying afterward.
Coprime numbers are the simplest case
When two numbers share no prime factors at all — like 7 and 13 — the GCF is always 1 and the LCM is always their product, 91. The calculator finds this instantly using Euclid's algorithm (gcd(a, b) = gcd(b, a mod b)) rather than factoring first, which matters once numbers get large: factoring a big number can be slow, but repeated division down to a remainder of zero is fast regardless of size.
Why zero isn't an accepted input
The calculator explicitly requires every number to be a positive whole number, rejecting zero outright rather than trying to compute a GCF or LCM involving it. That's not an arbitrary restriction: every number divides into zero evenly, so the 'greatest common factor' involving zero and anything else is just that other number, and the least common multiple involving zero is undefined (nothing times zero but zero ever equals zero, so there's no meaningful 'smallest positive multiple'). Rather than return a technically-defensible but confusing edge case, the tool asks for positive numbers only. Extending beyond two numbers works by folding the same pairwise operation across the whole list — gcd(a, b, c) is just gcd(gcd(a, b), c) — which is why the calculator accepts any count of numbers, not just two.
Related tools
- Number to Words Converter
Spell out numbers in English words — US or UK style, lakh/crore for South Asia — plus cheque-writing format with cents, for any number up to the quadrillions.
- Roman Numeral Converter
Convert numbers to Roman numerals and Roman numerals back to numbers (1–3,999), with validation of properly formed numerals.
- Polynomial Factoring Calculator
Factor polynomials with integer coefficients — common factors, rational roots, difference of squares and irreducible quadratics — and list all the roots.
- Slope, Distance & Midpoint Calculator
Find the slope, line equation (y = mx + b), distance, midpoint and angle between two points on a coordinate plane.
- Complex Number Calculator
Add, subtract, multiply and divide complex numbers, and convert between rectangular (a + bi) and polar form (r∠θ), with modulus and conjugate.
- Batch Rename Files
Rename many files at once — add numbering, dates, prefixes and suffixes, find and replace (with regex), change case or extension — preview every new name, then download as a ZIP or rename in place.