Menu

GCD and LCM Calculator

Compute the Greatest Common Divisor and the Least Common Multiple simultaneously with prime factorization.

Type the numbers separated by comma, space or semicolon. Positive integers only.

GCD (Greatest Common Divisor)

-

The largest number that divides all the entered values.

LCM (Least Common Multiple)

-

The smallest number that is a multiple of all the entered values.

Prime Factorization (Step by Step)

Numbers Prime Factor
Understand the calculation:

LCM calculation: Multiply all prime factors used in the factorization:

GCD calculation: Multiply only the prime factors that divided all numbers at the same time (marked with *):

All about GCD and LCM

The Greatest Common Divisor (GCD) is the largest positive integer that divides two or more numbers at the same time, with no remainder.

For example, consider the numbers 12 and 18:

  • Divisors of 12: 1, 2, 3, 4, 6, 12
  • Divisors of 18: 1, 2, 3, 6, 9, 18
  • Common divisors: 1, 2, 3, 6

The largest one is 6, therefore GCD(12, 18) = 6.

The Least Common Multiple (LCM) is the smallest nonโ€‘zero positive integer that is a multiple of two or more numbers at the same time.

Using the same numbers 12 and 18:

  • Multiples of 12: 12, 24, 36, 48, 60, 72...
  • Multiples of 18: 18, 36, 54, 72, 90...
  • Common multiples: 36, 72...

The smallest one is 36, therefore LCM(12, 18) = 36.

The most practical way to find both GCD and LCM at the same time is simultaneous prime factorization:

  1. Write the numbers side by side, separated by commas.
  2. Divide the numbers by the smallest possible prime number (2, 3, 5, 7...) that divides at least one of them.
  3. If a number is not divisible, simply repeat it on the next line.
  4. Continue the process until all numbers become 1.
  5. For the LCM: multiply all prime factors used.
  6. For the GCD: multiply only the prime factors that divided all numbers on that line at the same time.

Practical applications

When to use the GCD?

The GCD is useful for problems of division into equal parts with the largest possible size. Example: cutting boards of different lengths into equal pieces with maximum length, or dividing candies into equal bags with no leftovers.

When to use the LCM?

The LCM solves problems of cyclic events or simultaneous occurrences. Example: determining when two buses that leave at different intervals will depart together again, or in what interval two repeating events will coincide.