LCM or Least Common Multiple



Use this calculator to calculate the LCM (or Smallest Common Multiple) of two or more integers.
Enter positive integers separated by spaces to calculate their LCM. Example: 125 35 15 45

What is LCM ?

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

This definition can be easily extended to n integers. The LCM of n integers is the smallest positive common multiple of these n integers.

Example: what is the LCM of 28 and 42 ?

Multiples of 28 = 28, 56, 84, 112...
Multiples of 42 = 42, 84, 126...

The smallest number common to these two lists is 84. So,
LCM (28, 42) = 84.

How to calculate the LCM?

There are several methods for calculating LCM.

Multiple method: This is the method that derives directly from the definition.
- We list the multiples of the integers in question (e.g. using this calculator Find multiples of a number).
- The LCM is the smallest number common to these two lists.

Example: 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. We deduce,
LCM (6, 21) = 42

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

Factoring method

Example: What is the LCM of 48 and 42 ?

- Factorize the two numbers

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

- We will then calculate the LCM from the two integers decompositions into prime factors.
LCM factors will be the factors that are present in either 48 or 21 factors. Thus,
the LCM factors are therefore the union of the two factors sets: 2, 7 and 3

Each factor will have the largest exponent of the two decompositions. Thus,
2 will have an exponent of 4 (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|\div GCD (a, b) `

Thus, we can calculate the LCM from the GCD by applying this formula.

In the previous example (LCM of 48 and 42),

LCM (48, 42) = 48* 42\div GCD (48, 42)

Gold,

GCD (48, 42) = 6

So,

LCM (48, 42) = 48* 42\div 6 = 336`

Special Cases

- 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;

LCM Properties (Advanced)

a and b are two non-zero integers then,
- 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 choose the maximum from 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 le_ppcm 

See also

Multiples of a number
GCD
Factoring a number