Tech Study

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

Introduction

Write a Python program to get the least common multiple (LCM). 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

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

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

Java Final keyword

Introduction : java final keyword The final keyword present in Java programming language is generally used for restricting the user. …

Read more

C++ Memory Management: new and delete

C++ Memory Management We know that arrays store contiguous and the same type of memory blocks, so memory is allocated …

Read more