Last active
May 31, 2022 15:19
-
-
Save takakabe/5805325620ad5f0b005cfd117fc0396a to your computer and use it in GitHub Desktop.
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 sys | |
import math | |
args = sys.argv | |
value1 = int(args[1]) | |
value2 = int(args[2]) | |
i = 2 | |
divisor_list = [] | |
while i < value1 or i < value2: | |
if value1 % i == 0 and value2 % i == 0: | |
value1 = value1 // i | |
value2 = value2 // i | |
divisor_list.append(i) | |
i += 1 | |
gcd = math.prod(divisor_list) | |
print(gcd) |
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 sys | |
import math | |
args = sys.argv | |
value1 = int(args[1]) | |
value2 = int(args[2]) | |
i = 2 | |
divisor_list = [] | |
while i < value1 or i < value2: | |
if value1 % i == 0 and value2 % i == 0: | |
value1 = value1 // i | |
value2 = value2 // i | |
divisor_list.append(i) | |
i += 1 | |
divisor_list.append(value1) | |
divisor_list.append(value2) | |
lcm = math.prod(divisor_list) | |
print(lcm) |
Author
takakabe
commented
May 31, 2022
•
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment