Last active
March 19, 2024 16:16
-
-
Save MahraibFatima/0a503fe0e165e7742bd6d412ff97def6 to your computer and use it in GitHub Desktop.
Compute the least common multiple of the two input numbers.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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