Answer to Question #323903 in Python for vishnu

Question #323903

write a program to find the least common multiple of the given two numbers Mand N

1
Expert's answer
2022-04-05T10:36:31-0400

Apply the following set f codes to find the least common multiple:

# Find the L.C.M of two numbers
def lcm(m, n):
    """Returns L.C.M of two numbers."""
    if m > n:
        z = m
    else:
        z = n
    while True:
        if z % m == 0 and z % n == 0:
            lcm = z
            break
        z += 1
    return lcm


m = int(input("Enter first number: "))
n = int(input("Enter second number: "))
print("The L.C.M is:", lcm(m, n))

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS