Write a python function to calculate the least common multiple (LCM) of two user provided positive integers.


Topic: Write a python function to calculate the least common multiple (LCM) of two user provided positive integers.

Solution

def lcm(num1, num2):
   if num1 > num2:
       z = num1
   else:
       z = num2
   while(True):
       if((z % num1 == 0) and (z % num2 == 0)):
           lcm = z
           break
       z += 1
   return lcm



List all Python Programs