GCF & LCM Calculator
What's the GCF of 12 and 18 — and the LCM? Enter two to ten whole numbers and get both at once, with the prime factorizations that show why the answers are what they are.
Positive whole numbers only, e.g. 8, 12, 20
GCF
6
greatest common factor
LCM
36
least common multiple
Prime factorization
12 = 2² × 3 18 = 2 × 3² GCF: shared primes, lowest power → 2 × 3 = 6 LCM: all primes, highest power → 2² × 3² = 36
The GCF is found with Euclid's algorithm — replace the larger number with the remainder of the division until it hits 0 — one of the oldest algorithms still in daily use (Euclid's Elements, ~300 BC). The LCM follows for free: lcm(a, b) = a ÷ gcd(a, b) × b.
Lowest Powers Down, Highest Powers Up
Factor 12 = 2² × 3 and 18 = 2 × 3². The GCF takes only the primes both numbers share, at the lowest power each appears: 2 × 3 = 6. The LCM takes every prime that appears anywhere, at the highest power: 2² × 3² = 36. The shortcut connecting them is lcm(a, b) = a × b ÷ gcd(a, b) = 216 ÷ 6 = 36, and for longer lists the calculator folds pairwise — GCF(8, 12, 20) = 4 and LCM(8, 12, 20) = 120.
GCF vs LCM at a glance
GCF shared primes, lowest power 12 = 2²·3, 18 = 2·3² → 2·3 = 6 LCM all primes, highest power → 2²·3² = 36 Shortcut: lcm(a, b) = a × b ÷ gcd(a, b) = 216 ÷ 6 = 36 Lists fold pairwise: GCF(8, 12, 20) = 4, LCM(8, 12, 20) = 120 GCF use: simplifying fractions LCM use: common denominators
Frequently Asked Questions
What's the difference between GCF and LCM?
The GCF is the largest number that divides evenly into all of your inputs — for 12 and 18 it's 6. The LCM is the smallest number that all of your inputs divide into — for 12 and 18 it's 36. GCF shrinks (it can't exceed your smallest input); LCM grows (it's at least your largest).
How does Euclid's algorithm find the GCF?
Repeatedly replace the larger number with the remainder of dividing it by the smaller: gcd(18, 12) → gcd(12, 6) → gcd(6, 0) = 6. It works because any common divisor of two numbers also divides their remainder, and it's fast even for huge inputs — far faster than factoring.
How do I get the LCM from the GCF?
For two numbers, lcm(a, b) = a × b ÷ gcd(a, b): for 12 and 18 that's 216 ÷ 6 = 36. For longer lists, fold pairwise — take the LCM of the first two, then the LCM of that result with the next number — which gives LCM(8, 12, 20) = 120.
When do I actually need the LCM?
Any time cycles or denominators have to line up. Adding fractions uses it as the least common denominator (thirds and quarters meet at twelfths), and scheduling problems are the same math: buses every 8 minutes and every 12 minutes leave together every 24 minutes — the LCM of 8 and 12.