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

Online Exam Quiz for One day Exam Online Typing Test CCC Online Test 2026 Best Computer Training Institute in Prayagraj (Allahabad) Best Java Training Institute in Prayagraj (Allahabad) Best Python Training Institute in Prayagraj (Allahabad) O Level Online Test in Hindi Best Website and Software Company in Allahabad