Python program to find the LCM of two numbers.

In this python basic program, we will find the LCM two numbers defined by the user.

Steps to solve the program
  1. Take two numbers as input through the user.
  2. Using an if-else statement check which number is greater
  3. Use While loop.
  4. Inside the While loop check whether both numbers divide the greater number or not.
  5. If yes then break the loop otherwise, add 1 to the greater number and let the loop continue.
  6. At the end print the output.
				
					num1 = int(input("Enter number 1: "))
num2 = int(input("Enter number 2: "))

if num1 > num2:
       greater = num1
else:
    greater = num2

while(True):
    if((greater % num1 == 0) and (greater % num2 == 0)):
        lcm = greater
        break
    greater += 1
    
print(f"L.C.M of {num1} and {num2}: {lcm}")
				
			

Output :

				
					Enter number 1: 150
Enter number 2: 200
L.C.M of 150 and 200: 600
				
			

Program to find HCF

find the square root of a number.

Leave a Comment