GCD / LCM Calculator
Calculate the Greatest Common Divisor (GCD) and Least Common Multiple (LCM) of two or more numbers. Our free online calculator uses Euclid's algorithm for GCD and supports 2 to 6 numbers. Enter your values and get instant results for GCD, LCM, or both.
How it works
What is GCD (Greatest Common Divisor)?
The Greatest Common Divisor (GCD), also called the Greatest Common Factor (GCF) or Highest Common Factor (HCF), is the largest positive integer that divides two or more numbers without a remainder. For example, the GCD of 48 and 18 is 6, because 6 is the largest number that divides both 48 and 18 evenly.
What is LCM (Least Common Multiple)?
The Least Common Multiple (LCM) is the smallest positive integer that is a multiple of all given numbers. For example, the LCM of 12 and 18 is 36, because 36 is the smallest number that is a multiple of both 12 and 18.
Euclid's Algorithm
Our calculator uses Euclid's algorithm to compute the GCD. The algorithm states: gcd(a, b) = gcd(b, a mod b), repeating until b becomes 0. The GCD is then the non-zero remainder. This method is efficient and has been used for over 2,000 years.
How to Use the Calculator
Enter 2 to 6 positive integers separated by commas (e.g., 48, 18). Select whether you want to calculate GCD, LCM, or both. Click Calculate to see the result. For LCM with 3 or more numbers, the formula is: LCM(a, b, c) = LCM(LCM(a, b), c).
Examples
Example 1: GCD of 48 and 18
Input: 48, 18. GCD = 6. Euclid's steps: 48 mod 18 = 12, 18 mod 12 = 6, 12 mod 6 = 0. GCD = 6.
Example 2: LCM of 12 and 18
Input: 12, 18. LCM = 36. Formula: LCM = (12 × 18) / GCD(12, 18) = 216 / 6 = 36.
Example 3: GCD and LCM of 24, 36, 60
Input: 24, 36, 60. GCD = 12. LCM = 360. For three numbers, GCD is computed pairwise; LCM uses LCM(LCM(24, 36), 60).
Frequently Asked Questions
What happens if I enter 0?
GCD(0, n) = n. LCM is undefined when any number is 0, so the calculator will show an error.
Can I use negative numbers?
The calculator uses the absolute value of inputs, so -6 and 9 will give GCD = 3.
How many numbers can I enter?
You can enter 2 to 6 numbers. For more numbers, the same formulas apply: GCD reduces pairwise, LCM chains LCM(LCM(a,b), c), etc.
What is the GCD of two prime numbers?
If two numbers are prime and different, their GCD is 1. If they are the same prime, the GCD is that prime.
When is LCM used?
LCM is used for finding common denominators in fractions, scheduling recurring events, and solving problems involving multiples.