What is GCD (HCF)?
GCD (or HCF) is the largest integer that divides two (or more) integers exactly.
GCD stands for Greatest Common Divisor. In many school contexts it is called HCF (Highest Common Factor). Both mean the same thing.
You can think of the GCD as the “largest shared chunk size” that fits into both numbers with no remainder. It is used for simplifying fractions, reducing ratios, and grouping items evenly.
- GCD(12, 18) = 6
- Because 6 divides 12 and 18 exactly.
What is LCM?
LCM is the smallest positive integer that is a multiple of each input number.
LCM stands for Least Common Multiple. It is the first point where multiple repeating cycles “line up” again.
LCM is used for adding fractions (common denominator), scheduling problems (events repeating every N days), and synchronizing repeating patterns.
- LCM(4, 6) = 12
- Because 12 is the smallest number divisible by both 4 and 6.
GCD vs LCM (Differences)
GCD helps with simplification; LCM helps with alignment.
GCD answers: “What is the biggest shared factor?” LCM answers: “What is the smallest shared multiple?”
They are complementary. For two numbers a and b (not both zero), there is a useful relationship between them: GCD(a,b) × LCM(a,b) = |a×b|.
- For 12 and 18:
- GCD = 6
- LCM = 36
- 6 × 36 = 216 = |12 × 18|
| Feature | GCD (HCF) | LCM |
|---|---|---|
| Meaning | Greatest common divisor | Least common multiple |
| Typical use | Simplify fractions/ratios | Common denominators/schedules |
| Size | Usually smaller | Usually larger |
Euclidean Algorithm (Steps)
The fastest way to compute GCD uses repeated division with remainder.
Euclidean algorithm repeatedly applies: a = q×b + r. Replace (a, b) with (b, r) until the remainder is 0. The last non-zero remainder is the GCD.
This method is efficient and works well even for large integers compared to listing factors.
- 252 = 2×105 + 42
- 105 = 2×42 + 21
- 42 = 2×21 + 0
- GCD = 21
Prime Factorization Method
GCD uses the minimum shared prime powers; LCM uses the maximum prime powers.
Write each number as a product of primes. The GCD is formed by taking primes common to all numbers with the smallest exponent. The LCM is formed by taking primes appearing in any number with the largest exponent.
This method is excellent for understanding, but for big numbers it can be slow compared to Euclid.
- 12 = 2^2 × 3
- 18 = 2 × 3^2
- GCD = 2^1 × 3^1 = 6
- LCM = 2^2 × 3^2 = 36
Relationship: GCD × LCM
For two numbers a and b, GCD(a,b) × LCM(a,b) = |a×b| (unless both are 0).
This identity is a great sanity check and helps derive LCM from GCD. It holds for integers with the common convention GCD(0,0)=0 and LCM(0,0)=0.
If either number is 0, the LCM is 0 (because every multiple of 0 is 0), and the GCD is the absolute value of the other number.
- a=0, b=15
- GCD(0,15)=15
- LCM(0,15)=0
GCD/LCM of Multiple Numbers
Compute across many numbers by chaining pairwise results: GCD(GCD(a,b),c)... and similarly for LCM.
Most calculators (including ours) compute the result across multiple numbers by reducing the list step by step. This is reliable and easy to explain.
Important: if all inputs are 0, both GCD and LCM are defined as 0. If some are 0, the GCD ignores zeros naturally, while LCM becomes 0 if any input is 0.
- GCD(24, 36, 60) = 12
- LCM(3, 4, 6) = 12
Real-World Use Cases
GCD simplifies; LCM synchronizes.
GCD: simplifying fractions (12/18 → 2/3), reducing ratios (20:30 → 2:3), dividing items into equal groups.
LCM: scheduling (events every 6 and 8 days align every 24 days), adding fractions (common denominator), repeating patterns.
- Bus A every 6 days, Bus B every 8 days
- They align every LCM(6,8)=24 days
Quick Reference
Keep these formulas handy for exams and quick checks.
GCD and LCM are easiest when you remember a few safe formulas and special cases.
For two integers a and b (not both zero): LCM(a,b) = |a/GCD(a,b)| × |b|. If either input is 0, LCM is 0.
- GCD(a,0)=|a|
- LCM(a,0)=0
- If GCD(a,b)=1 ⇒ LCM(a,b)=|a×b|
| Scenario | GCD | LCM |
|---|---|---|
| a and b are coprime | 1 | |a×b| |
| a = b | |a| | |a| |
| one input is 0 | |other| | 0 |
FAQs
Is GCD the same as HCF?
What is GCD(0, 0)?
What is LCM(a, 0)?
How do you find LCM using GCD?
Can LCM be smaller than both numbers?
Want step-by-step for multiple numbers?
Open the full calculator to compute GCD/LCM for 2–10 integers, with optional Euclidean chains and prime factor visuals.