How it works
The GCF (greatest common factor) is found with the Euclidean algorithm: repeatedly replace the larger number with the remainder of dividing it by the smaller one until the remainder is zero — whatever's left is the GCF. The LCM (least common multiple) follows directly from it. With three or four numbers, the calculator reduces pairwise — GCF(a, b, c) = gcd(gcd(a, b), c), and the same for LCM.
gcd(a, b): while b ≠ 0, (a, b) = (b, a mod b); result is a
lcm(a, b) = (a × b) ÷ gcd(a, b)
Worked examples
Two numbers, then three, to show how the reduction extends.
- gcd(18, 12): 18 mod 12 = 6.
- gcd(12, 6): 12 mod 6 = 0, so the GCF is 6.
- LCM = (12 × 18) ÷ 6 = 216 ÷ 6 = 36.
GCF = 6, LCM = 36.
- gcd(12, 18) = 6, then gcd(6, 30) = 6 — the GCF is 6.
- lcm(12, 18) = 36, then lcm(36, 30) = (36 × 30) ÷ gcd(36, 30) = 1080 ÷ 6 = 180.
GCF = 6, LCM = 180.
Common questions
What's the difference between GCF and LCM?
GCF (greatest common factor) is the largest number that divides evenly into all the numbers you entered. LCM (least common multiple) is the smallest number that all of them divide evenly into — they answer opposite kinds of questions.
How does the Euclidean algorithm work?
It repeatedly replaces the larger number with the remainder of dividing it by the smaller one, until the remainder is zero — whatever's left is the GCF. It's dramatically faster than checking every possible factor, especially for large numbers.
What are GCF and LCM actually used for?
GCF is used to reduce fractions to lowest terms (divide numerator and denominator by their GCF). LCM is used to find a common denominator when adding or comparing fractions with different denominators.