🔢 GCF & LCM Calculator
Find the greatest common factor and least common multiple of 2 or more numbers, with the full Euclidean algorithm worked out step by step.
Step by step: the Euclidean algorithm
Each row divides the larger number by the smaller and keeps the remainder, until a remainder of 0 is reached — the last non-zero divisor is the greatest common factor of that pair.
| Larger (a) | Smaller (b) | a mod b (remainder) |
|---|---|---|
| 18 | 12 | 6 |
| 12 | 6 | 0 (GCF = 6) |
LCM is then computed from each GCF using LCM(a, b) = (a ÷ GCF(a, b)) × b, so it never needs its own separate list of factors.
What GCF & LCM Calculator Does
Greatest common factor and least common multiple are two sides of the same relationship between numbers, and both are computable without ever listing out factors by hand — the method that scales to large numbers is the Euclidean algorithm, a repeated-division process that has been the standard way to compute GCF since antiquity. Most calculators for this exact query show only the final answer; the real gap, visible in what people actually search for alongside this tool ("gcf and lcm calculator with steps"), is that showing the answer without the working is not actually more useful than a mental-math shortcut for small numbers, and is useless for checking a homework answer.
The Euclidean algorithm itself is short: divide the larger number by the smaller, keep the remainder, and repeat with (smaller, remainder) in place of the original pair. When the remainder hits zero, the divisor at that last step is the GCF. LCM then follows directly from the GCF — LCM(a, b) = (a ÷ GCF(a, b)) × b — so no second, independent method is needed once the GCF is known.
For three or more numbers, the same two operations fold pairwise: GCF(n1, n2, n3) = GCF(GCF(n1, n2), n3), and likewise for LCM. This tool shows every pairwise fold's full Euclidean trace, not just a final answer, for exactly that reason.
How to Use GCF & LCM Calculator
- Enter 2 or more positive whole numbers, adding rows as needed
- Read the GCF and LCM, plus the full Euclidean algorithm trace for each pairwise step
- For exactly two numbers, use the GCF × LCM = a × b identity to check your own work
Formula Used by GCF & LCM Calculator
Euclidean algorithm for GCF
GCF(a, b) = GCF(b, a mod b), repeated until the remainder is 0
Worked example
GCF(18, 12) — the exact example Google shows as a related search for this tool's own query.
- 18 mod 12 = 6 → new pair (12, 6)
- 12 mod 6 = 0 → remainder is 0, so the GCF is the divisor at this step: 6
Result: GCF(12, 18) = 6 — confirmed in node -e before publishing.
LCM from GCF
LCM(a, b) = (a ÷ GCF(a, b)) × b
Worked example
LCM(12, 18), using the GCF of 6 computed above.
- (12 ÷ 6) × 18 = 2 × 18 = 36
Result: LCM(12, 18) = 36 — matching the exact "GCF 6, LCM 36" result for this well-known example pair.
The GCF × LCM identity (two numbers only)
GCF(a, b) × LCM(a, b) = a × b
Worked example
The same pair, 12 and 18.
- GCF × LCM = 6 × 36 = 216
- a × b = 12 × 18 = 216
Result: Both equal 216 — a quick way to check a hand-worked GCF/LCM answer, though it only holds for exactly two numbers, not three or more.
GCF and LCM for commonly searched number pairs
Every value below was computed with the same Euclidean-algorithm code this tool runs, not looked up separately.
| Pair | GCF | LCM |
|---|---|---|
| 4 and 6 | 2 | 12 |
| 6 and 8 | 2 | 24 |
| 8 and 12 | 4 | 24 |
| 9 and 12 | 3 | 36 |
| 12 and 16 | 4 | 48 |
| 12 and 18 | 6 | 36 |
| 15 and 20 | 5 | 60 |
| 16 and 24 | 8 | 48 |
| 18 and 24 | 6 | 72 |
| 20 and 30 | 10 | 60 |
| 24 and 36 | 12 | 72 |
How to Read Your Result
Coprime numbers are a normal result, not an error
When two numbers share no factor besides 1 — 8 and 15, for example — their GCF is 1, and their LCM is simply their product. This is a correct, complete answer, not a sign that something went wrong.
Why folding works for 3+ numbers
GCF and LCM are both associative in the same sense addition is: it does not matter which pair is combined first, the final result across the whole list is the same. That is what makes the pairwise-folding approach exact rather than an approximation.
A bigger GCF does not predict a bigger or smaller LCM
Look at 12 and 18 (GCF 6, LCM 36) against 16 and 24 (GCF 8, LCM 48): the larger GCF pair also has the larger LCM here, but that is not a rule — the identity GCF × LCM = a × b means LCM depends on the product of the two numbers as much as on how much they share. Do not try to estimate one from the other without the actual multiplication.
Limitations & Accuracy Notes
- Defined only for positive whole numbers — GCF and LCM are not defined for zero, negative numbers, or non-integers, and the tool reports an error for those inputs rather than guessing an answer.
- Caps input at safe-integer values (numbers JavaScript can represent exactly), since larger inputs would silently lose precision rather than give a wrong-looking but plausible answer.