GCD and LCM Calculator
The GCD (Greatest Common Divisor) is the largest number that divides two or more integers without a remainder. The LCM (Least Common Multiple) is the smallest number divisible by all given integers. Use the Euclidean algorithm: gcd(a, b) = gcd(b, a mod b). Key relationship: GCD(a, b) x LCM(a, b) = a x b. Example: GCD(12, 18) = 6, LCM(12, 18) = 36.
Calculate the Greatest Common Divisor (GCD) and Least Common Multiple (LCM) of two or more numbers. Step-by-step Euclidean algorithm, presets, and verification.
Enter Numbers
Separate numbers with commas or spaces
Quick Reference
| Numbers | GCD | LCM |
|---|---|---|
| 12, 18 | 6 | 36 |
| 24, 36 | 12 | 72 |
| 15, 25 | 5 | 75 |
| 7, 13 | 1 | 91 |
| 100, 75 | 25 | 300 |
Formulas
- GCD: Euclidean algorithm — gcd(a, b) = gcd(b, a mod b)
- LCM: lcm(a, b) = |a x b| / gcd(a, b)
- Relationship: GCD(a, b) x LCM(a, b) = |a x b|
How to Use
- 1
Enter your numbers
Type 2 or more positive integers separated by commas or spaces (e.g. 12, 18 or 24 36 48)
- 2
Click Calculate
Press Calculate or hit Enter to compute the GCD and LCM simultaneously
- 3
View the results
See the GCD and LCM displayed side by side, with a verification showing GCD x LCM = a x b
- 4
Review the steps
For two numbers, view the step-by-step Euclidean algorithm showing each division and remainder
- 5
Copy the result
Click Copy to copy both GCD and LCM values to your clipboard
Frequently Asked Questions
- What is the GCD of two numbers?
- The GCD (Greatest Common Divisor), also called HCF (Highest Common Factor) or GCF (Greatest Common Factor), is the largest positive integer that divides both numbers without a remainder. For example, GCD(12, 18) = 6 because 6 is the largest number that divides both 12 and 18 evenly. The GCD is always at least 1, since 1 divides every integer.
- What is the LCM of two numbers?
- The LCM (Least Common Multiple) is the smallest positive integer that is divisible by both numbers. For example, LCM(12, 18) = 36 because 36 is the smallest number that both 12 and 18 divide into evenly. The LCM is used in adding fractions with different denominators — you find the LCD (Least Common Denominator), which is the LCM of the denominators.
- How do you find GCD using the Euclidean algorithm?
- The Euclidean algorithm finds the GCD by repeatedly dividing the larger number by the smaller and taking the remainder. Steps: (1) Divide a by b, get remainder r. (2) Replace a with b, b with r. (3) Repeat until remainder is 0. The last non-zero remainder is the GCD. Example: GCD(48, 18): 48 ÷ 18 = 2 remainder 12, then 18 ÷ 12 = 1 remainder 6, then 12 ÷ 6 = 2 remainder 0. GCD = 6.
- What is the relationship between GCD and LCM?
- For any two positive integers a and b: GCD(a, b) × LCM(a, b) = a × b. This means LCM(a, b) = (a × b) / GCD(a, b). For example, with 12 and 18: GCD = 6, so LCM = (12 × 18) / 6 = 216 / 6 = 36. This formula provides an efficient way to calculate LCM once you know the GCD.
- What is the GCD of 12 and 18?
- GCD(12, 18) = 6. The factors of 12 are 1, 2, 3, 4, 6, 12. The factors of 18 are 1, 2, 3, 6, 9, 18. The common factors are 1, 2, 3, 6. The greatest (largest) of these is 6. Using the Euclidean algorithm: 18 ÷ 12 = 1 remainder 6, then 12 ÷ 6 = 2 remainder 0, so GCD = 6.
- How do you find the LCM of three numbers?
- To find the LCM of three or more numbers, calculate pairwise: LCM(a, b, c) = LCM(LCM(a, b), c). For example, LCM(4, 6, 10): first LCM(4, 6) = 12, then LCM(12, 10) = 60. You can also use prime factorization: take the highest power of each prime across all numbers. 4 = 2², 6 = 2 × 3, 10 = 2 × 5, so LCM = 2² × 3 × 5 = 60.