LCM and GCD Calculator

Find the Least Common Multiple (LCM) or Greatest Common Divisor (GCD/GCF) of up to 5 numbers. See step-by-step prime factorization and Euclidean algorithm solutions.

Least Common Multiple
Enter 2 to 5 positive integers.
Result
Answer with step-by-step solutions.

Enter numbers and click Calculate to see the result.

How to Calculate LCM and GCD

LCM — Least Common Multiple

The smallest number that all given numbers divide into evenly. Used for adding fractions with different denominators.

Example: LCM(4, 6)

4 = 2²
6 = 2 × 3
LCM = 2² × 3 = 12

GCD — Greatest Common Divisor

The largest number that divides all given numbers without a remainder. Used to simplify fractions to lowest terms.

Example: GCD(12, 18)

12 = 2² × 3
18 = 2 × 3²
GCD = 2 × 3 = 6

Two Methods Explained

Prime Factorization Method

  1. Factor each number into primes.
  2. For LCM: take the highest power of each prime.
  3. For GCD: take the lowest power of each prime that appears in all numbers.
  4. Multiply the selected prime powers together.

Euclidean Algorithm (GCD)

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

GCD(48, 18) → 48 mod 18 = 12 → 18 mod 12 = 6 → 12 mod 6 = 0 → GCD = 6

LCM × GCD = a × b

For any two positive integers, the product of their LCM and GCD equals the product of the numbers themselves. This useful shortcut lets you find one from the other.

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

Example: LCM(12, 18) × GCD(12, 18) = 36 × 6 = 216 = 12 × 18 ✓

Frequently Asked Questions

What is LCM (Least Common Multiple)?

The Least Common Multiple (LCM) of two or more integers is the smallest positive integer that is divisible by all of them. For example, LCM(4, 6) = 12 because 12 is the smallest number divisible by both 4 and 6. LCM is used to find common denominators when adding or subtracting fractions.

What is GCD (Greatest Common Divisor)?

The Greatest Common Divisor (GCD), also called Greatest Common Factor (GCF) or Highest Common Factor (HCF), is the largest positive integer that divides all given numbers without a remainder. For example, GCD(12, 18) = 6 because 6 is the largest number that divides both 12 and 18 evenly. GCD is used to simplify fractions.

How do you calculate LCM?

There are two common methods. (1) Prime Factorization: write each number as a product of prime factors, then take the highest power of each prime that appears in any factorization and multiply them together. (2) LCM Formula: LCM(a, b) = (a × b) / GCD(a, b). For more than two numbers, apply this formula step by step: LCM(a, b, c) = LCM(LCM(a, b), c).

How do you calculate GCD using the Euclidean algorithm?

The Euclidean algorithm is the most efficient method. To find GCD(a, b): divide a by b and get the remainder r. Then GCD(a, b) = GCD(b, r). Repeat until the remainder is 0 — the last non-zero remainder is the GCD. Example: GCD(48, 18): 48 = 2×18 + 12; 18 = 1×12 + 6; 12 = 2×6 + 0; so GCD = 6.

What is the relationship between LCM and GCD?

For any two positive integers a and b: LCM(a, b) × GCD(a, b) = a × b. This means you can always calculate one from the other. For example, if GCD(12, 18) = 6, then LCM(12, 18) = (12 × 18) / 6 = 216 / 6 = 36. This relationship only holds for exactly two numbers.

Related Calculators

Share This Calculator

Found this tool helpful?

Help others discover it with one click.

Copy Link

Suggested hashtags: #calculator #Calculator #FreeTools #AICalculator