LCM of Two numbers - Learn Engineering

All the news and updates relevant to Engineering. You can also Write a post here

Breaking

Friday, June 19, 2020

LCM of Two numbers

python-mini

Question

To Print the LCM of two numbers.

Sample TestCaseExpected Output

Enter First number :  2                                                                                       LCM is  4

Enter Second number : 4

Answer


a=int(input("Enter first number : "))
b=int(input("Enter second number : "))
if(a>b):
    min1=a
else:
    min1=b
while(1):
    if(min1%a==0 and min1%b==0):
        print("LCM is : ",min1)
        break
    min1+=1

No comments:

Post a Comment