Skip to content

Instantly share code, notes, and snippets.

@MahraibFatima
Last active March 19, 2024 16:16
Show Gist options
  • Save MahraibFatima/0a503fe0e165e7742bd6d412ff97def6 to your computer and use it in GitHub Desktop.
Save MahraibFatima/0a503fe0e165e7742bd6d412ff97def6 to your computer and use it in GitHub Desktop.
Compute the least common multiple of the two input numbers.
def compute_lcm(x, y):
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
num1 = int(input("Enter first number: "))
num2 = int(input("Enter second number: "))
print("LCM:", compute_lcm(num1, num2))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment