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 2021 CCC Practice Test Hindi Python Programming Tutorials 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 Bank SSC Railway TET UPTET Question Bank career counselling in allahabad Sarkari Naukari Notification Best Website and Software Company in Allahabad Sarkari Exam Quiz