By: Editorial Staff | Last Updated:
In today’s tutorial, we are going to share a Python program to find the LCM. If you are a python beginner and want to start learning the python programming, then keep your close attention in this tutorial as I am going to share a Python program to find the LCM.
def lcm(x, y):
if x > y:
greater = x
greater = y
if((greater % x == 0) and (greater % y == 0)):
lcm = greater
greater += 1
num1 = int(input("Enter first number: "))
num2 = int(input("Enter second number: "))
print("The L.C.M. of", num1,"and", num2,"is", lcm(num1, num2))
The L.C.M. of 12 and 20 is 60
To increase your Python knowledge, practice all Python programs, here is a collection of 100+ Python problems with solutions.
Editorial Staff at FreeWebMentor is a team of professional developers leads by Prem Tiwari View all posts by Editorial Staff