Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def gcd(a, b):
- while a != 0 and b != 0:
- if a > b:
- a = a % b
- else:
- b = b % a
- return a + b
- def lcm(a, b):
- return a * b // gcd(a, b)
- gcd_n = 0
- lcm_n = 1
- n = int(input())
- while n != 0:
- gcd_n = gcd(gcd_n, n)
- lcm_n = lcm(lcm_n, n)
- n = int(input())
- print('НОД:', gcd_n)
- print('НОК:', lcm_n)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement