Q:

Write a Python program to get the least common multiple (LCM)

belongs to collection: python basic programs with examples

0

Write a Python program to get the least common multiple (LCM)

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

I have used python 3.7 compiler for debugging purpose.

 def lcm(a, b):
   if a > b:
       z = a
   else:
       z = b
 
   while(True):
       if((z % a == 0) and (z % b == 0)):
           lcm = z
           break
       z += 1
 
   return lcm
print(lcm(10, 20))
print(lcm(15, 17))

Result:

20

255

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

python basic programs with examples

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
Write a Python program that will accept the base a... >>
<< Write a Python program to compute the greatest com...