LCM of Two Numbers in Python

Problem: Write a python program to find lcm (least common multiple) of two numbers.

Solution: Here are the steps to find least common multiple (LCM) of two numbers in python.
  1. Accept two numbers from user.
  2. Find the greater number among two input numbers
  3. Check if the greater number is divisible by smaller number, if yes, greater number is the lcm of two input numbers.
  4. If greater number is not divisible by aller number them increment greater number by 1 and continue this process until you get least common multiple of two numbers.

Python program to find LCM of two numbers

Here is the source code of program for LCM of two numbers in python.
#Python program to find lcm of two given numbers

def find_lcm(a, b):
   if a > b:
       greater = a
       greater = b
       if((greater % a == 0) and (greater % b == 0)):
           lcm = greater
       greater += 1
   return lcm

number1 = int(input("Enter first number: "))
number2 = int(input("Enter second number: "))
print("The LCM of two numbers is", find_lcm(number1, number2))


Enter first number: 95
Enter second number: 101
The LCM of two numbers is 9595