LCM:-
Least Common Multiple(LCM) is a method to find the smallest common multiple between any two or more numbers. A common multiple is a number which is a multiple of two or more numbers.
code:-
def lcm(a, b):
if a > b:
z = a
else:
z = b
while(True):
if((z % a == 0) and (z % b == 0)):
lcm = z
break
z += 1
return lcm
print(lcm(10, 22))
print(lcm(16, 18))
output:-
110
144
144
Post a Comment
If you have any doubts, Please let me know
Thanks!