python-dev avatar

Python Program to Find LCM

python-dev

Published: 22 Mar 2020 › Updated: 22 Mar 2020Python Program to Find LCM

Python Program to Find LCM

# Python Program to find the L.C.M. of two input 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

num1 = 54
num2 = 24

print("The L.C.M. is", compute_lcm(num1, num2))

Leave Python Program to Find LCM to:

Written by

Read more #python-dev posts


Best Posts From python-dev

We have not curated any of python-dev's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.

More Posts From python-dev