GCD & LCM Calculator

Part of Math & Statistics Calculators

Calculate the Greatest Common Divisor (GCD) and Least Common Multiple (LCM) of two or more numbers.

Enter two or more positive integers separated by commas

What are GCD and LCM?

The Greatest Common Divisor (GCD), also called the Greatest Common Factor (GCF) or Highest Common Factor (HCF), is the largest positive integer that divides each of the given numbers without 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.

The Least Common Multiple (LCM), also called the Lowest Common Multiple, is the smallest positive integer that is divisible by each of the given numbers. For example, the LCM of 4 and 6 is 12, because 12 is the smallest number that both 4 and 6 divide into evenly.

How to Calculate GCD

The most efficient method for calculating GCD is the Euclidean algorithm, one of the oldest algorithms still in common use today. The algorithm is based on the principle that the GCD of two numbers also divides their difference.

Euclidean Algorithm Steps:

  1. Divide the larger number by the smaller number and find the remainder.
  2. Replace the larger number with the smaller number, and the smaller number with the remainder.
  3. Repeat until the remainder is 0. The last non-zero remainder is the GCD.

For multiple numbers, calculate GCD pairwise: GCD(a,b,c) = GCD(GCD(a,b), c).

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. For multiple numbers, calculate LCM pairwise: LCM(a,b,c) = LCM(LCM(a,b), c).

How to Use This Calculator

  1. Enter your numbers: Type two or more positive integers separated by commas. For example: 12, 18, 24
  2. Calculate: Click "Calculate GCD & LCM" to compute both values simultaneously.
  3. View results: The calculator displays both the GCD and LCM, along with the calculation method used.
  4. Multiple numbers: The calculator supports any quantity of numbers, not just two.

Real-World Applications

Simplifying fractions: GCD is used to reduce fractions to lowest terms. To simplify 12/18, divide both numerator and denominator by GCD(12,18) = 6 to get 2/3.

Finding common denominators: LCM helps find common denominators when adding fractions. To add 1/4 + 1/6, use LCM(4,6) = 12 as the common denominator.

Scheduling problems: If two events occur every 4 days and 6 days respectively, they'll coincide every LCM(4,6) = 12 days.

Tiling and patterns: When tiling a floor with different sized tiles, LCM helps determine when patterns repeat. GCD helps find the largest square tile that can evenly cover rectangular dimensions.

Music theory: LCM determines when different rhythmic patterns align. GCD helps find common beats between different time signatures.

Mathematical Properties

GCD properties: GCD(a,a) = a, GCD(a,1) = 1, GCD(a,0) = a. GCD is commutative and associative.

LCM properties: LCM(a,a) = a, LCM(a,1) = a. LCM is also commutative and associative.

Relationship: For any two numbers a and b: GCD(a,b) × LCM(a,b) = a × b

Coprime numbers: If GCD(a,b) = 1, the numbers are coprime (relatively prime), meaning they share no common factors except 1. For coprime numbers, LCM(a,b) = a × b.

Historical Context

The Euclidean algorithm for finding GCD appears in Euclid's Elements (circa 300 BCE), making it one of the oldest algorithms in continuous use. Its efficiency and elegance have made it foundational in number theory and computer science. The algorithm's time complexity is proportional to the number of digits in the smaller number, making it remarkably fast even for very large numbers.

GCD is essential for simplifying fractions in the Fraction Calculator. The Prime Number Checker can help find the prime factors needed for manual GCD/LCM calculation.