LCM of n numbers in python by R4R Team

What is LCM-
LCM stands for lowest common multiple

Example -
let we have a two number 10 and 12 then common multiple of these two number is 60,120,180,....
but lowest one is 60,
so we can conclude that LCM of 10 and 12 is 60

LCM of 2,4 and 5 is 20
LCM of 10,12 and 13 is 780

Program -

def check(l,n):
for i in l:
if n%i!=0:
return 0
return 1

print("Enter numbers to find the LCM")
if check(l,m):
print("LCM is - "+str(m))

output -

Enter numbers to find the LCM
10 12 13 20
LCM is - 780

Enter numbers to find the LCM
3 4 1 6 7
LCM is - 84

In this program, check() function is used to check that the number is common factor of all number or not. - we make a list of input numbers and take the maximum out of them and increase that number one by one and for each value we called check() function.

Leave a Comment:
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!