LCM Of Two Numbers In Python Using While Loop

(Last Updated On: 21/11/2022)

Python Program to Find LCM of Two Numbers Using While Loop

#LCM Of Two Numbers In Python Using While Loop

# we are taking a number from user as input
# entered value will be converted to int from string
a=int(input("Enter the first number:"))
b=int(input("Enter the second number:"))

maximum = max(a, b)

# while loop is used whose condition is always true (or 1)
while(1):
	if(maximum %a==0 and maximum %b==0):
    	print("LCM is:",maximum)
    	break
	maximum=maximum+1

Output:

Enter the first number:5
Enter the second number:10
LCM is: 10

Leave a Reply

Your email address will not be published. Required fields are marked *