# LCM or Least Common Multiple

**Smallest Common Multiple**) of two or more numbers.

Enter numbers separated by space(s).

## What is LCM ?

The LCM (or Least Common Multiple) of two (or more) non zero integers is the smallest positive common multiple of these numbers.

## How to calculate the LCM?

There are several methods to calculate LCM.

### Multiples method

This is the method that derives directly from the definition.

• List the multiples of the integers in question (you may use this calculator Find multiples of a number).

• The LCM is the smallest common number to these two lists.

**Example 1.** What is the LCM of 6 and 21?

Multiples of 6 = 6, 12, 18, 24, 30, 36, **42**...

Multiples of 21 = 21, **42**, 63...

The smallest common number of these bumbers is 42. So,

LCM (6, 21) = 42

**Example 2.** what is the LCM of 28 and 42 ?

Multiples of 28 = 28, 56, **84**, 112...

Multiples of 42 = 42, **84**, 126...

The smallest common number of these two lists is 84. So,

LCM (28, 42) = 84

This method is not recommended because it requires calculating multiples of the integers, which can be long and tedious for large numbers. The two methods below are faster.

### Factors method

**Example.** What is the LCM of 48 and 42 ?

• Factor the two numbers

`48 = 2^4 * 3` (factorize 48)

`42 = 2 * 7 * 3` (factorize 42)

• Calculate the LCM from the two integers prime factorization.

LCM factors will be the same factors that are present in either 48 or 42 prime factorizations.

LCM factors are therefore the union of the two factors sets: 2, 7 and 3

Each factor will have the largest exponent in the two decompositions. Thus,

2 will have an exponent of 4 (since 4 > 1 ).

3 will have an exponent of 1 (same exponent in the two decompositions).

7 will have an exponent of 1 (present only in 42).

So,

`LCM (48, 42) = 2^4 * 3* 7 = 336`

### GCD Method

This method uses the following formula:

`LCM (a, b)*GCD (a,b) = a*b`

We deduce,

`LCM (a,b)=(a*b)/(GCD (a, b))`

We calculate LCM from GCD by using this formula.

Applied to above example,

`LCM(48,42)=(48*42)/(GCD(48,42))`

We have,

So,

`LCM(48,42)=(48*42)/6 = 336`

## LCM Properties (Advanced)

Let a and b be two non-zero integers then,

• if b is a divisor of a, then the LCM of a and b is equal to a.

• if a or b is zero, LCM (a, b) = 0

• GCD (a, b) divides LCM (a, b)

• If we multiply a and b by the same positive integer k then their LCM is multiplied by k.

LCM (k.a, k. b) = k . LCM (a, b)

• GCD (a, b) x LCM (a, b) = |a x b|

• a and b are two positive coprime integers if and only if LCM (a , b) = a x b.

## Programming

Here is a program that computes the LCM of two integers.### Python

```
def lcm (x, y):
# we calculate the maximum of x and y
if x > y:
max = x
else:
max = y
while (True):
if ((max % x == 0) and (max % y == 0)):
lcm = max
break
max += 1
return lcm
```

## See also

Multiples of a number

GCD

Factoring a number