GCD & LCM Calculator
Calculate the Greatest Common Divisor (GCD) and Least Common Multiple (LCM) of up to 5 numbers, with prime factorization for each.
How to Use
Enter 2 to 5 whole numbers. The calculator finds the GCD (also called HCF — Highest Common Factor) and LCM, showing the prime factorization of each number.
The Extended Calculator adds Euclidean algorithm steps, a Venn diagram of prime factors, and coprimality checking. The Professional Calculator includes the Extended Euclidean algorithm (Bezout's identity), multi-number GCD/LCM for up to 10 numbers, and Euler's totient function.
Euclidean Algorithm Steps
| Step | Division | Remainder |
|---|---|---|
| 1 | 48 = 2 × 18 + 12 | 12 |
| 2 | 18 = 1 × 12 + 6 | 6 |
| 3 | 12 = 2 × 6 + 0 | 0 |
| GCD | 6 | |
GCD and LCM Formulas
GCD (Euclidean algorithm): gcd(a, b) = gcd(b, a mod b) until b = 0
LCM from GCD: lcm(a, b) = |a × b| / gcd(a, b)
GCD × LCM = a × b (for two numbers)
Bezout's Identity: There exist integers s, t such that gcd(a,b) = s·a + t·b
Worked Example
GCD and LCM of 12 and 18:
12 = 2² × 3 | 18 = 2 × 3²
GCD = 2 × 3 = 6
LCM = 2² × 3² = 36
Check: 6 × 36 = 216 = 12 × 18 ✓
Back-Substitution Steps
| Step | a | b | Quotient | Remainder |
|---|---|---|---|---|
| 1 | 252 | 105 | 2 | 42 |
| 2 | 105 | 42 | 2 | 21 |
| 3 | 42 | 21 | 2 | 0 |