Table of Contents
Python program to find LCM
Python program to find LCM : LCM is Least Common Multiple/Lowest Common Multiple is smallest integer which is divided by both the numbers. LCM of 6 and 8 is 24.
Logic to find LCM in python
def lcm(x, y):
z = x if x > y else y
temp = z
while(True):
if((z % x == 0) and (z % y == 0)):
return z
z += temp
a = int(input("Enter first number : "))
b = int(input("Enter second number : "))
c = lcm(a,b)
print("LCM of %d and %d is %d"%(a,b,c))
Output :
Enter first number : 12
Enter second number : 18
LCM of 12 and 18 is 36
We are aiming to explain all concepts of python in easiest terms as possible.

ITVoyagers
Author
PRACTICALS/PRACTICE PROGRAM IN PYTHON
CHECKOUT OTHER RELATED TOPICS
CHECKOUT OTHER QUIZZES
Quizzes on File Handling |
Easy quiz on file handling in python part 1 |
Easy quiz on file handling in python part 2 |
Quizzes on Exception Handling |
Easy quiz on Exception Handling in python part 1 |
Easy Quiz on Exception Handling in python part 2 |
Quizzes on Regular Expressions |
Easy Quiz on Regular Expression in python part 1 |
Quizzes on Python concepts coming soon… |
Python basic quiz |
New and easy python quiz basic part 1 |
New and easy python quiz (basic) part 2 |
New and easy python quiz (basic) part 3 |
Python practice quiz set |
Best Practice Quiz Set on Python Programming Part 1 |
Best Practice Quiz Set on Python Programming Part 2 |
Best Practice Quiz Set on Python Programming Part 3 |
Best Practice Quiz Set on Python Programming Part 4 |
Best Practice Quiz Set on Python Programming Part 5 |