Python Program To Find LCM Of Two Numbers

Python Program To Find LCM Of Two Numbers

Example

def lcmCalculation(x, y):  
    
    greater = max(x,y)
    
    while(True):  
        if((greater % x == 0) and (greater % y == 0)):  
            lcm = greater  
            break  
        greater += 1  
    return lcm    
  

N1 = 25
N2 = 16
LCM = lcmCalculation(N1, N2)

print("The LCM of {} and {} is : {}".format(N1,N2,LCM))  

Output:

The LCM of 25 and 16 is : 400

Leave a comment