freeCodeCamp/guide/english/mathematics/least-common-multiple/index.md

28 lines
1.2 KiB
Markdown
Raw Normal View History

2018-10-12 19:37:13 +00:00
---
title: Least Common Multiple
---
## Least Common Multiple
The least common multiple (LCM) of two or more numbers is the smallest number (not counting 0) which is a multiple of all of the numbers.<br />
A common multiple is a number that is a multiple of two or more numbers. The common multiples of 4 and 5 are 0, 20, 40... <br />
The least common multiple (LCM) of two numbers is the smallest number (not zero) that is a multiple of both.<br />
Multiples of 4: 0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44...<br />
Multiples of 5: 0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55...<br />
Clearly, the Least Common Multiple of 4 and 5 is 20.
### Let us learn how to calculate the Least Common Multiple
#### Step 1: List down all the prime factors of each number
e.g. Consider the numbers 30 and 40.<br />
30 = 2 x 3 x 5 <br />
40 = 2 x 2 x 2 x 5<br />
#### Step 2: Multiply each factor the greatest number of times it occurs in either number. If the same factor occurs more than once in both numbers, you multiply the factor the greatest number of times it occurs.<br />
Occurences of 2: 3<br />
Occurences of 3: 1<br />
Occurences of 5: 1<br />
LCM(30,40) = 2 x 2 x 2 x 3 x 5 = 120<br />