Skip to content
DEVELOGCALC

GCF and LCM Calculator

Find the greatest common factor and least common multiple of two or more whole numbers, with each number’s prime factorization.

Try:

2 to 20 numbers. Don’t use commas inside a number.

Result

Greatest common factor (GCF / GCD): 8

Greatest common factor (GCF / GCD)

Least common multiple (LCM)
168
Relatively prime?
No
NumberPrime factorization
242³ × 3
562³ × 7
Calculation steps
  1. GCF: Euclid’s algorithm, gcd(a, b) = gcd(b, a mod b), applied across the list
  2. GCF = 8
  3. LCM: lcm(a, b) = a ÷ gcd(a, b) × b, applied across the list
  4. LCM = 168

Calculations run in your browser. Your inputs are not sent to our server.

Formula

  • GCF(a, b) = GCF(b, a mod b), GCF(a, 0) = a
  • LCM(a, b) = a × b ÷ GCF(a, b)
  • For more numbers: GCF(a, b, c) = GCF(GCF(a, b), c), same for LCM

How it works

The greatest common factor comes from Euclid’s algorithm: replace the larger number by its remainder when divided by the smaller one until the remainder is zero. The last non-zero value divides every number in the list. The least common multiple follows from it, because a × b = GCF × LCM for any two numbers.

The prime factorizations show the same answer another way. The GCF takes each prime that appears in every number, at its lowest power; the LCM takes every prime that appears anywhere, at its highest power. Integer arithmetic is exact, so even large LCMs are shown in full.

Worked examples

24 and 56

24 = 2³ × 3 and 56 = 2³ × 7, so the GCF is 2³ = 8 and the LCM is 2³ × 3 × 7 = 168.

Whole numbers
24, 56
Greatest common factor (GCF / GCD)
8

Common denominator for 1/4, 1/6, 1/15

The LCM of the denominators is 60, the least common denominator; the GCF is 1.

Whole numbers
4 6 15
Greatest common factor (GCF / GCD)
1

Where GCF and LCM are used

  • Simplifying fractions: divide top and bottom by their GCF (18/24 → 3/4).
  • Adding fractions: the LCM of the denominators is the least common denominator.
  • Scheduling: two events every 6 and 8 days coincide every LCM(6, 8) = 24 days.
  • Tiling or cutting: the largest equal square that fits a 24 × 56 area has side GCF = 8.

Relatively prime numbers

Numbers whose GCF is 1, such as 8 and 15, share no prime factor. Their LCM is simply their product.

Last reviewed: