LCM & GCD Calculator

Calculate the Least Common Multiple (LCM) and Greatest Common Divisor (GCD) of two or more numbers instantly, with step-by-step prime factorization.

Least Common Multiple (LCM)

Enter two or more positive integers separated by commas or spaces.

How to Use This Tool

  1. Choose LCM or GCD/HCF using the mode tabs.
  2. Enter two or more positive integers, separated by commas or spaces.
  3. The result updates instantly as you type.
  4. Review the prime factorization breakdown shown below the result for each number entered.

Formula & How It Works

GCD (Euclidean Algorithm)

GCD(a, b) = GCD(b, a mod b), until b = 0

Repeatedly replace the larger number with the remainder of dividing it by the smaller number, until the remainder is zero — the last non-zero remainder is the GCD.

LCM from GCD

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

Once the GCD of two numbers is known, the LCM is found by dividing the product of the numbers by their GCD.

Multiple Numbers

LCM(a, b, c, …) = LCM(LCM(a, b), c, …)

For more than two numbers, the LCM (or GCD) is computed by combining the numbers pairwise, left to right.

Practical Examples & Common Use Cases

Example: GCD of 12 and 18

GCD(12, 18): 18 mod 12 = 6, then 12 mod 6 = 0, so GCD(12, 18) = 6.

Example: LCM of 4 and 6

GCD(4, 6) = 2, so LCM(4, 6) = (4 × 6) / 2 = 24 / 2 = 12.

Example: LCM of 12, 18, and 24

LCM(12, 18) = 36, then LCM(36, 24) = 72, so LCM(12, 18, 24) = 72.

Frequently Asked Questions

The Greatest Common Divisor (GCD), also called HCF or GCF, is the largest positive integer that divides all of the given numbers. For example, GCD(12, 18) = 6.

The Least Common Multiple (LCM) is the smallest positive integer that is divisible by all the given numbers. For example, LCM(4, 6) = 12.

For two numbers a and b: LCM(a, b) = (a × b) / GCD(a, b). Knowing one lets you quickly find the other.

LCM is used when adding or subtracting fractions (to find the common denominator), and for scheduling problems like finding when recurring events coincide.

Related Tools