Программа:
from math import gcd, lcm
n, a = int(input()), []
while n != 0:
a += [n]
n = int(input())
print(f'НОД: {gcd(*a)}\nНОК: {lcm(*a)}')
Программа:
from math import gcd, lcm
n, a = int(input()), []
while n != 0:
a += [n]
n = int(input())
print(f'НОД: {gcd(*a)}\nНОК: {lcm(*a)}')