Programming Examples

Python program to find the LCM of two input numbers


Write a Python program to input 2 numbers and fin the LCM.

Solution

n1=int(input("Enter Number 1 : "))
n2=int(input("Enter Number 2 : "))
if n1 > n2:
    greater = n1
else:
    greater = n3
while(True):
    if((greater % n1 == 0) and (greater % n2 == 0)):
        lcm = greater
        break
    greater += 1
print("L.C.M. : ",lcm)
Output

Enter Number 1 : 21

Enter Number 2 : 5

L.C.M. :  105

CCC Online Test Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Online Exam Quiz O Level NIELIT Study material and Quiz Bank SSC Railway TET UPTET Question Bank career counselling in allahabad Best Website and Software Company in Allahabad Website development Company in Allahabad