GCF & LCM Calculator

Find the greatest common factor (GCF/HCF) and least common multiple (LCM) of two or more numbers, with the prime factorizations shown.

GCF: the biggest shared divisor

The greatest common factor (also called HCF or GCD) of a set of numbers is the largest whole number that divides every one of them. This calculator finds it with the Euclidean algorithm, applied pairwise across your list: gcd(a, b) = gcd(b, a mod b) until the remainder hits zero.

GCF(a, b, c) = GCF(GCF(a, b), c) · LCM(a, b) = a ÷ GCF(a, b) × b

Worked example: 12, 18, 30

Prime factorizations: 12 = 2² × 3, 18 = 2 × 3², 30 = 2 × 3 × 5. The GCF takes each prime to the lowest power appearing in all three: 2 × 3 = 6. The LCM takes each prime to the highest power anywhere: 2² × 3² × 5 = 180. Pairwise, the Euclidean route gives gcd(12, 18) = 6, then gcd(6, 30) = 6; and lcm(12, 18) = 12 ÷ 6 × 18 = 36, then lcm(36, 30) = 180.

Why compute LCM via the GCF?

Multiplying first (a × b ÷ GCF) can overflow for large inputs, so the calculator divides first: a ÷ GCF × b. Inputs are capped at 10¹², and if a set's LCM grows beyond what integers can represent exactly (about 9 × 10¹⁵), the calculator says so rather than showing a silently rounded value.

Where you will actually use these

The GCF is the number you divide by to reduce a fraction or ratio to lowest terms — it is why 12/18 simplifies to 2/3. The LCM is the common denominator when adding fractions (1/12 + 1/18 = 3/36 + 2/36), the answer to scheduling questions ("gym every 12 days, pool every 18 — both on day 36"), and the cycle length of repeating patterns. The prime factorization table under the result shows exactly where both numbers come from.

Frequently asked questions

What is the difference between GCF and LCM?
The GCF (greatest common factor, also called HCF or GCD) is the largest number that divides all of your numbers; the LCM (least common multiple) is the smallest number they all divide into. For 12, 18 and 30 the GCF is 6 and the LCM is 180.
How does the Euclidean algorithm find the GCF?
It repeatedly replaces the larger number with the remainder of dividing it by the smaller: gcd(18, 12) → gcd(12, 6) → gcd(6, 0) = 6. It is dramatically faster than listing factors, even for huge numbers.
How are GCF and LCM related?
For two numbers, GCF × LCM = a × b. That is why the calculator computes LCM as a ÷ GCF × b — it reuses the GCF and avoids overflow from multiplying big numbers first.
What are GCF and LCM used for?
GCF simplifies fractions and ratios (12/18 → 2/3) and splits things into equal groups. LCM finds common denominators for adding fractions, and answers "when do repeating events coincide?" — buses every 12 and 18 minutes meet every 36 minutes.
Why positive integers only?
Factors and multiples are defined for whole numbers. Zero is a special case (every number divides 0, so LCM with 0 is 0), and it isn’t useful in practice, so this calculator asks for positive whole numbers.