Last active
November 1, 2021 02:09
-
-
Save maxfire2008/2bf5e24452f8ed2649cb1459b6a1d654 to your computer and use it in GitHub Desktop.
Find lowest common multiple for a given number
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
import random | |
while True: | |
numbers_str = input("Enter a number to find the LCM for (csv):") | |
if not numbers_str: | |
break | |
numbers_int = [] | |
for number in numbers_str.split(","): | |
numbers_int.append(int(number)) | |
current = 1 | |
while True: | |
is_multiple = True | |
current_actual = min(numbers_int)*current | |
for n in numbers_int: | |
if current_actual % int(n) != 0: | |
is_multiple = False | |
if is_multiple: | |
print("LCM is",current_actual) | |
break | |
current += 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment