Skip to content
Toolcroft

Math Calculators

GCD & LCM Calculator - Greatest Common Divisor & Least Common Multiple

Calculate the greatest common divisor (GCD) and least common multiple (LCM) of up to 50 integers. Shows step-by-step Euclidean algorithm work and prime factorization for each number.

GCD (Greatest Common Divisor)

6

LCM (Least Common Multiple)

72

Greatest Common Divisor (GCD)

The GCD of two integers is the largest integer that divides both numbers without a remainder. It is also called the greatest common factor (GCF) or highest common factor (HCF). The Euclidean algorithm (developed around 300 BCE) computes it efficiently by repeatedly taking remainders: GCD(a, b) = GCD(b, a mod b).

Least Common Multiple (LCM)

The LCM is the smallest positive integer divisible by all given numbers. It is essential for adding fractions with different denominators and for scheduling problems involving repeating events. The LCM is related to the GCD by: LCM(a, b) = a × b ÷ GCD(a, b).

Using prime factorization

An alternative way to find GCD and LCM uses prime factorizations. For the GCD, take each prime that appears in all factorizations, raised to the minimum exponent. For the LCM, take each prime that appears in any factorization, raised to the maximum exponent.

Euclidean algorithm step-by-step

Stepaba mod b
1481812
218126
31260
GCD6 (last non-zero remainder)

Applications

  • Simplifying fractions: divide numerator and denominator by their GCD to reduce to lowest terms. 48/18 ÷ 6/6 = 8/3.
  • Scheduling: if event A repeats every 18 days and event B every 48 days, LCM = 144 gives the next day they coincide.
  • Music theory: polyrhythms use LCM to find when beat cycles realign - a 3-against-4 pattern realigns every LCM(3,4) = 12 beats.
  • Gear ratios: GCD simplifies ratio expressions; LCM finds when gear teeth realign.

Extended Euclidean algorithm

The extended Euclidean algorithm finds integers x, y such that ax + by = GCD(a, b) (Bézout's identity). This has direct applications in modular arithmetic and is the basis of the RSA encryption algorithm's key generation step, where the multiplicative inverse modulo a number is computed using the extended GCD.