Python program to Find LCM of Number

def LCM(x,y):
 z = x*y
 while x != 0 and y != 0:
     if x > y:
        x %= y
     else:
        y %= x
 return z//(x+y)
a = int(input("Insert value of a: "))
b = int(input("Insert value of b: "))
print("The LCM = ", LCM(a,b))

 

 

 

Output:

 

Insert value of a: 4
Insert value of b: 2
The LCM =  4

 

Insert value of a: 90
Insert value of b: 180
The LCM =  180

 

 

Subscribe For Daily Updates

100+ Python Pattern Examplespython pattern examples - star patterns, number patterns