Question 5
Smallest Multiple
Code:
# Set p p=1 # define a function def LCM(x, y): """This function takes two integers and returns the L.C.M.""" # choose the greater number if x > y: greater = x else: greater = y while(True): if((greater % x == 0) and (greater % y == 0)): lcm = greater break greater += 1 return lcm # For loop for i in range(1,21): # Lowest common multiple p=LCM(i,p) # Print P print(p)