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)
▶ RUN

Output/ Explanation:

Enter Number 1 : 21

Enter Number 2 : 5

L.C.M. :  105

Latest Current Affairs 2025 Online Exam Quiz for One day Exam Online Typing Test CCC Online Test Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Online MBA 2 years Online MCA Online BCA Best Website and Software Company in Allahabad