🔢 GCD & LCM Calculator

Calculate Greatest Common Divisor and Least Common Multiple

📊 Enter Numbers

📊 Your Results

Greatest Common Divisor (GCD)

--

Least Common Multiple (LCM)

--

📝 Calculation Steps

📚 Understanding GCD and LCM

What is GCD (Greatest Common Divisor)?

The Greatest Common Divisor (GCD), also known as the Greatest Common Factor (GCF) or Highest Common Factor (HCF), is the largest positive integer that divides both numbers without leaving a remainder. For example, the GCD of 12 and 18 is 6, because 6 is the largest number that divides both 12 and 18 evenly.

What is LCM (Least Common Multiple)?

The Least Common Multiple (LCM) is the smallest positive integer that is divisible by both numbers. For example, the LCM of 12 and 18 is 36, because 36 is the smallest number that both 12 and 18 divide into evenly.

How to Calculate GCD

The most efficient method to calculate GCD is the Euclidean Algorithm:

How to Calculate LCM

The LCM can be calculated using the relationship with GCD:

LCM(a, b) = (a × b) / GCD(a, b)

This formula works because the product of two numbers equals the product of their GCD and LCM.

Real-World Applications

Properties of GCD and LCM

Frequently Asked Questions

What's the difference between GCD and LCM?

GCD is the largest number that divides both numbers evenly, while LCM is the smallest number that both numbers divide into evenly. GCD is always less than or equal to the smaller number, while LCM is always greater than or equal to the larger number.

Can GCD and LCM be calculated for more than two numbers?

Yes! For multiple numbers, calculate GCD or LCM pairwise. For example, GCD(a, b, c) = GCD(GCD(a, b), c). The same applies to LCM. This calculator focuses on two numbers for simplicity.

What are coprime numbers?

Two numbers are coprime (or relatively prime) if their GCD is 1. For example, 8 and 15 are coprime because GCD(8, 15) = 1. Coprime numbers have no common factors other than 1.

How is the Euclidean Algorithm efficient?

The Euclidean Algorithm is very efficient because it reduces the problem size rapidly with each step. It has a time complexity of O(log min(a, b)), making it much faster than checking all possible divisors, especially for large numbers.

Why is LCM(a, b) = (a × b) / GCD(a, b)?

This formula works because the product of two numbers contains all their prime factors. The GCD contains the common factors, so dividing by GCD removes the duplicate factors, leaving only the factors needed for the LCM.

What happens if one number is a multiple of the other?

If one number is a multiple of the other (e.g., 6 and 18), then the GCD is the smaller number (6) and the LCM is the larger number (18). This is because the smaller number divides the larger one perfectly.