GCF and LCM Calculator

Find the greatest common factor and least common multiple of two or more whole numbers, with prime factorizations.

Two or more positive integers

Greatest common factor (GCF)
6
Your numbers, their GCF and LCM
05010015020012 — Value: 121218 — Value: 181830 — Value: 3030GCF — Value: 6GCFLCM — Value: 180LCM
Least common multiple (LCM)
180
Prime factorizations
12 = 2² × 3; 18 = 2 × 3²; 30 = 2 × 3 × 5
Show the working
  1. 12 = 2² × 3
  2. 18 = 2 × 3²
  3. 30 = 2 × 3 × 5
  4. GCF: take each prime the numbers share, with its smallest power → 2 × 3 = 6
  5. LCM: take every prime that appears, with its largest power → 2² × 3² × 5 = 180

Runs entirely in your browser. Nothing you enter is uploaded.

Formula

GCF = product of shared primes, each to its lowest powerLCM = product of all primes, each to its highest powerFor two numbers: GCF(a, b) × LCM(a, b) = a × b

How it works

The greatest common factor (GCF, also called the greatest common divisor or highest common factor) is the largest number that divides evenly into every number in the list. The least common multiple (LCM) is the smallest number that every number in the list divides into.

Prime factorization makes both easy. Write each number as a product of primes. The GCF uses only the primes that all the numbers share, each raised to the smallest power that appears. The LCM uses every prime that appears anywhere, raised to the largest power.

You will use the GCF to simplify fractions (divide top and bottom by it) and the LCM to add fractions (it is the least common denominator). Behind the scenes, this calculator uses Euclid’s algorithm, which finds the GCF by repeatedly replacing the larger number with the remainder of a division.

Frequently asked questions

What is the GCF of two prime numbers?

It is always 1, because primes have no factors other than 1 and themselves. Numbers whose GCF is 1 are called coprime or relatively prime.

How does Euclid’s algorithm work?

Divide the larger number by the smaller and keep the remainder. Then repeat with the smaller number and that remainder. When the remainder hits 0, the last non-zero remainder is the GCF. For 48 and 18: 48 mod 18 = 12, 18 mod 12 = 6, 12 mod 6 = 0, so the GCF is 6.

esc