1. Home
  2. /
  3. Blog
  4. /
  5. Python Program to Find LCM
Python

Python Program to Find LCM

September 27, 2022 1 min read 2,169
Python Program to Find LCM
num = int(input("Enter a number: "))


def compute_lcm(x, y):

   # choose the greater number
   if x > y:
       greater = x
   else:
       greater = y

   while(True):
       if((greater % x == 0) and (greater % y == 0)):
           lcm = greater
           break
       greater += 1

   return lcm

n1 = 54
n2 = 24

print("The L.C.M. is", compute_lcm(n1,n2))

Share:
Read next

Related articles