GCD & LCM Calculator

Math Calculators
GCD & LCM Calculator
Results
GCD (Greatest Common Divisor)
LCM (Least Common Multiple)
Copy this code to embed: <iframe src="../../calculators/math/gcd-lcm-calculator?embed=1.html" width="100%" height="500" frameborder="0" style="border:1px solid #e2e8f0;border-radius:8px;"></iframe>
Advertisement
How to Use This Calculator

How to Use the GCD & LCM Calculator

The GCD and LCM Calculator finds the Greatest Common Divisor (GCD) and Least Common Multiple (LCM) of two or more integers. These fundamental number theory operations are essential in fraction simplification, scheduling problems, and many areas of mathematics.

Entering Values

Type two or more positive integers separated by commas. For example, enter 12, 18 to find that their GCD is 6 and their LCM is 36. You can enter as many numbers as needed for multi-number GCD and LCM calculations.

Understanding GCD

The Greatest Common Divisor (also called Highest Common Factor or HCF) is the largest positive integer that divides all given numbers without a remainder. For 24 and 36, the divisors of 24 are {1, 2, 3, 4, 6, 8, 12, 24} and the divisors of 36 are {1, 2, 3, 4, 6, 9, 12, 18, 36}. The greatest common one is 12.

Understanding LCM

The Least Common Multiple is the smallest positive integer that is divisible by all given numbers. For 4 and 6, multiples of 4 are {4, 8, 12, 16, ...} and multiples of 6 are {6, 12, 18, ...}. The least common one is 12. The relationship between GCD and LCM is: GCD(a,b) × LCM(a,b) = a × b.

The Euclidean Algorithm

This calculator uses the Euclidean algorithm, one of the oldest known algorithms. It works by repeatedly replacing the larger number with the remainder of dividing the larger by the smaller. For GCD(48, 18): 48 mod 18 = 12, then 18 mod 12 = 6, then 12 mod 6 = 0. So GCD = 6.

Practical Applications

The GCD simplifies fractions: 12/18 becomes 2/3 by dividing both by GCD(12,18) = 6. The LCM finds common denominators when adding fractions: 1/4 + 1/6 needs LCD = LCM(4,6) = 12. LCM also solves scheduling problems, like when two buses with different intervals will next depart simultaneously.

Frequently Asked Questions

Q: What is the GCD of two prime numbers?

A: The GCD of any two distinct prime numbers is always 1, because prime numbers have no common factors other than 1. Such numbers are called coprime or relatively prime.

Q: Can I find the GCD of more than two numbers?

A: Yes. The calculator supports multiple numbers. It computes GCD by finding the GCD of the first two numbers, then finding the GCD of that result with the third number, and so on. The same chaining approach works for LCM.

Q: What if one of the numbers is zero?

A: GCD(a, 0) = a for any non-zero a, because every integer divides zero. LCM(a, 0) = 0 by convention. The calculator handles zero inputs correctly.

Advertisement
Advertisement