🔢 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.

Free No Signup Required Browser-Based
Greatest Common Factor
6
of 12, 18
Least Common Multiple
36
of 12, 18

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)
18126
1260 (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.

Check your work
For exactly two numbers, GCF × LCM always equals the product of the two numbers themselves: 12 × 18 = 216, and 6 × 36 = 216 — they match.

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

  1. Enter 2 or more positive whole numbers, adding rows as needed
  2. Read the GCF and LCM, plus the full Euclidean algorithm trace for each pairwise step
  3. 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.

  1. 18 mod 12 = 6 → new pair (12, 6)
  2. 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.

  1. (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.

  1. GCF × LCM = 6 × 36 = 216
  2. 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.

PairGCFLCM
4 and 6212
6 and 8224
8 and 12424
9 and 12336
12 and 16448
12 and 18636
15 and 20560
16 and 24848
18 and 24672
20 and 301060
24 and 361272

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.

Frequently Asked Questions

What is the GCF and LCM of 12 and 18?
The GCF is 6 and the LCM is 36. The Euclidean algorithm gets the GCF in two steps: 18 mod 12 = 6, then 12 mod 6 = 0, so the last non-zero remainder's divisor, 6, is the GCF. LCM follows from GCF: (12 ÷ 6) × 18 = 36.
How do you find GCF and LCM with steps shown?
For GCF, repeatedly divide the larger number by the smaller and replace the pair with (smaller, remainder) until the remainder is 0 — the Euclidean algorithm. The last non-zero remainder's divisor is the GCF. For LCM, no separate steps are needed: LCM(a, b) = (a ÷ GCF(a, b)) × b.
How do you find GCF and LCM of 3 or more numbers?
Fold them two at a time: compute GCF(n1, n2), then GCF of that result with n3, and so on — the same approach for LCM. This calculator shows every pairwise fold's full Euclidean trace, not just the final answer.
What if two numbers share no common factor besides 1?
They are called coprime, and their GCF is 1 — a real, valid result, not an error. Their LCM is simply the product of the two numbers, since (a ÷ 1) × b = a × b.
By OnlineToolHubs Team • September 2026