Find the Greatest Common Divisor and Least Common Multiple of two or more numbers, with the full Euclidean algorithm laid out step by step — not just the final answer.
The Greatest Common Divisor (GCD) and Least Common Multiple (LCM) are two of the most important concepts in elementary number theory, with applications from simplifying fractions in middle school to cryptographic algorithms that secure the internet.
The Euclidean algorithm, described by Euclid around 300 BC, is one of the oldest and most efficient algorithms in mathematics. It computes the GCD in O(log(min(a,b))) steps, terminating rapidly even for very large numbers. The algorithm applies the identity: GCD(a, b) = GCD(b, a mod b) repeatedly until the remainder is zero.
This calculator shows the complete Euclidean algorithm step by step for two numbers, and also computes GCD and LCM for lists of multiple numbers using the generalization: GCD(a, b, c) = GCD(GCD(a, b), c).
Find GCD(48, 18): 48 = 2×18 + 12 → 18 = 1×12 + 6 → 12 = 2×6 + 0. GCD = 6. LCM = |48×18|/6 = 864/6 = 144. Check: 144/48 = 3 ✓, 144/18 = 8 ✓.
Apply the Euclidean algorithm to find GCD(48, 18)
Division steps (Euclidean algorithm)
48 = 2 × 18 + 12 → 18 = 1 × 12 + 6 → 12 = 2 × 6 + 0
GCD(48, 18) = last non-zero remainder
LCM = |a × b| / GCD
LCM(48, 18)
• GCD(a, b) × LCM(a, b) = |a × b|
• GCD(a, 0) = a (any number is divisible by itself)
• If GCD(a, b) = 1, then a and b are co-prime (relatively prime)
• The Euclidean algorithm runs in O(log(min(a,b))) time
• LCM is used for adding fractions with different denominators