Answers for "27. What is the least common multiple ( LCM ) for numbers 9 and 12 ? *"

C++
0

get the least common multiple (LCM) of two positive integers

def lcm(x, y):
   if x > y:
       z = x
   else:
       z = y

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

   return lcm
print(lcm(4, 6))
print(lcm(15, 17))
Posted by: Guest on July-07-2020

Code answers related to "27. What is the least common multiple ( LCM ) for numbers 9 and 12 ? *"

Browse Popular Code Answers by Language