GCD & LCM Calculator

Greatest common divisor and lowest common multiple of two whole numbers.

GCD & LCM calculator
GCD (HCF)
LCM
GCD and LCM explained
The Greatest Common Divisor (GCD) — also called HCF — is the largest number that divides both inputs exactly. The Least Common Multiple (LCM) is the smallest number that both inputs divide into exactly.
LCM(a, b) = (a × b) ÷ GCD(a, b)
1
GCD is found using Euclid's algorithm: repeatedly replace the larger number with the remainder of dividing the two
2
GCD(48, 18): 48 mod 18 = 12 → 18 mod 12 = 6 → 12 mod 6 = 0 → GCD = 6
3
LCM(48, 18) = (48 × 18) ÷ 6 = 864 ÷ 6 = 144
💡 Real use: GCD is used to simplify fractions. LCM is used to find a common denominator when adding fractions.

Two fundamental building blocks of number theory

The greatest common divisor (GCD, also called the highest common factor or HCF) and the lowest common multiple (LCM) are pair-of-numbers tools you first meet at school but keep using for life — especially when working with fractions. The GCD is the largest number that divides both inputs exactly; the LCM is the smallest number that both inputs divide into exactly.

How to use the calculator

Enter two whole numbers and the calculator returns both their GCD and their LCM. It handles large numbers instantly using an efficient method rather than listing out every factor.

How the answers are found

The GCD is calculated with Euclid's algorithm, one of the oldest algorithms still in use: repeatedly replace the larger number with the remainder of dividing the two, until the remainder is zero. For 48 and 18: 48 mod 18 = 12, then 18 mod 12 = 6, then 12 mod 6 = 0, so the GCD is 6. The LCM then follows from a neat relationship: LCM(a, b) = (a × b) ÷ GCD(a, b), which gives (48 × 18) ÷ 6 = 144.

Why they matter

The GCD is what you use to simplify a fraction to its lowest terms — divide the top and bottom by their GCD. The LCM gives you the lowest common denominator when adding or subtracting fractions with different denominators. Outside the classroom, the LCM answers scheduling puzzles like "two buses leave every 15 and 20 minutes — when do they next leave together?" (every 60 minutes).

Frequently asked questions

What is the difference between GCD and LCM?

The GCD (or HCF) is the largest number that divides both inputs exactly. The LCM is the smallest number that both inputs divide into exactly.

How are GCD and LCM related?

LCM(a, b) = (a × b) ÷ GCD(a, b). Finding the GCD first (via Euclid’s algorithm) makes the LCM easy.