GCF and LCM Calculator

Find the greatest common factor and least common multiple of two or more whole numbers, with prime factorisations, Euclid’s algorithm, every common factor and a Venn diagram of the shared primes.

Calculator Numbers & Math Updated Oct 3, 2026
How to Use
  1. Type two or more whole numbers separated by commas or spaces, up to 20 numbers of up to 40 digits each.
  2. Read the GCF (also called the GCD or HCF) and the LCM, whether the numbers are coprime, and how many factors they share.
  3. Show Work gives Euclid’s algorithm for the first two numbers and the prime factorisation of each.
  4. For two or three numbers the Venn diagram puts shared primes in the overlap: the overlap multiplies to the GCF, everything multiplies to the LCM.
  5. The table lists every common factor; click any value to copy it.
Input
2 to 20
Presets
Shared prime factors
GCF
—
LCM
—
Coprime
—
Common factors
—

Worked Example

12 and 18 by prime factors. 12 = 2 × 2 × 3 and 18 = 2 × 3 × 3. They share one 2 and one 3, so GCF = 6. Everything that appears, taking the most of each prime, is 2 × 2 × 3 × 3, so LCM = 36. Check: 12 × 18 = 216 = 6 × 36.

48 and 180 by Euclid’s algorithm. 180 = 3 × 48 + 36; 48 = 1 × 36 + 12; 36 = 3 × 12 + 0. The last non-zero remainder is 12, and LCM = 48 × 180 ÷ 12 = 720.

The common mistake: multiplying to get the LCM. 12 × 18 = 216 is a common multiple, but not the least. Multiply, then divide by the GCF: 216 ÷ 6 = 36.

Show Work

Enter numbers to see the step-by-step working.

Formulas

Euclid
GCF(a, b) = GCF(b, a mod b), GCF(a, 0) = a
GCF from primes
∏ p^min(eᵢ)
LCM from primes
∏ p^max(eᵢ)
Two numbers
GCF × LCM = a × b
Many numbers
GCF(a, b, c) = GCF(GCF(a, b), c)

The Oldest Algorithm

Euclid’s algorithm appears in Book VII of the Elements, written around 300 BC, and is often called the oldest algorithm still in everyday use. Euclid described it with lengths, repeatedly taking the shorter from the longer; Chinese mathematicians used the same method in the Nine Chapters to simplify fractions.

In 1844 Gabriel Lamé proved that it never needs more steps than five times the number of digits in the smaller number, the first real analysis of how fast an algorithm runs; the worst cases are consecutive Fibonacci numbers. Today it runs inside every RSA key generator and every program that simplifies fractions.

About This Calculator

This calculator finds the GCF and LCM of up to 20 whole numbers of up to 40 digits, exactly. It shows Euclid’s algorithm, factors each number (using Pollard’s rho method for large factors), lists every common factor, and draws the shared primes in a Venn diagram for two or three numbers.

Everything runs in your browser; nothing is sent anywhere.

Related calculators: Prime Factorization Calculator, Fraction Calculator, and Ratio Calculator.

Frequently Asked Questions

How do I find the GCF?

Either factor both numbers and multiply the primes they share, each to its lowest power, or use Euclid’s algorithm: divide the larger by the smaller, then the smaller by the remainder, until the remainder is 0. For 48 and 180: 180 = 3 × 48 + 36, 48 = 1 × 36 + 12, 36 = 3 × 12 + 0, so GCF = 12. Euclid’s way needs no factoring, so it works on numbers of any size.

How do I find the LCM?

Multiply every prime that appears in any of the numbers, each to its highest power. 12 = 2² × 3 and 18 = 2 × 3², so LCM = 2² × 3² = 36. For two numbers there is a shortcut: LCM = a × b ÷ GCF = 12 × 18 ÷ 6 = 36.

What are GCD and HCF?

Other names for the same thing. Greatest common divisor (GCD) is the usual term in higher mathematics and programming; highest common factor (HCF) is common in British schools; greatest common factor (GCF) in American ones. They all mean the largest number that divides every number in the list.

What does coprime mean?

Two numbers are coprime (or relatively prime) when their GCF is 1, so they share no prime factor. 8 and 15 are coprime even though neither is prime. For coprime numbers the LCM is simply their product: LCM(8, 15) = 120.

When do I need the GCF or the LCM?

The GCF simplifies fractions (18/24 ÷ 6 = 3/4) and finds the largest equal pieces something can be cut into. The LCM finds a common denominator for adding fractions and the next time repeating events line up: buses every 12 and 18 minutes leave together every 36 minutes.

How do I use the GCF and LCM Calculator?

Just type your numbers. The answer shows up right away — there is no button to press. Change anything and it updates by itself.

Do I need to install or sign up for anything?

Not at all — it runs in the browser with nothing to install and no account. After it loads once, it even works without an internet connection.

Is my information private?

Yes. Everything happens in your browser. Nothing you type is sent to a server or saved anywhere.

Common Use Cases

Fractions

GCF(18, 24) = 6 simplifies 18/24 to 3/4.

Schedules

Buses every 12 and 18 minutes meet every LCM = 36 minutes.

Tiling

The largest square tile for a 48 × 180 cm floor is 12 cm.

Gears

Gears of 12 and 30 teeth realign after LCM = 60 teeth: 5 and 2 turns.

Party bags

12 pencils and 18 stickers make at most 6 identical bags.

Last updated: