Created
September 17, 2022 19:41
-
-
Save modos/71915fc51f5069a803a4cb03ac8ea8e7 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
m, n = input().split() | |
m = int(m) | |
n = int(n) | |
# gcdlkhlihljkhklj | |
if m == 1 or n == 1: | |
gcd = 1 | |
lcm = m*n | |
else: | |
if m <= n: | |
smal_number = m | |
big_number = n | |
else: | |
smal_number = n | |
big_number = m | |
counter = 2 | |
gcd = 1 | |
while counter <= smal_number: | |
if big_number % counter == 0 and smal_number % counter == 0: | |
big_number = big_number//counter | |
smal_number = smal_number//counter | |
gcd *= counter | |
counter = 1 | |
counter += 1 | |
# Least Common Multiple | |
lcm = m*n//gcd | |
print(gcd, lcm) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment