LCM of two numbers In Python
The Least Common Multiple (LCM) of a group of numbers is the smallest number that is a multiple of all the numbers.
Program:
a = int(input("Enter FIrst numbers"))
b = int(input("Enter Second numbers"))
lc = 0
if(a > b):
lcm = a
else:
lc = b
while(1):
if( lc % a == 0 and lc % b == 0 ):
print("LCM of",a,"and",b,"is",lc)
break
lc = lc + 1
OutPut:
Enter FIrst numbers7
Enter Second numbers21
LCM of 7 and 21 is 21
No comments:
Post a Comment