def get_max_num(m, n):
while n != 0:
temp = m % n
m, n = n, temp
return m
if __name__ == "__main__":
while True:
temp = input('请输入两个数字,m和n,逗号结束:')
if temp == '0,0':
print('程序结束运行!')
break
try:
m, n = temp.split(',')
m = eval(m)
n = eval(n)
except Exception as e:
print(e)
continue
if (isinstance(m, int) and isinstance(n, int)) is False:
print('请确保m和n是个整数')
continue
if m <= 0 or n <= 0:
print('输入的数字不能小于等于0')
continue
result = get_max_num(m, n)
print(f"{m},{n}的最大公约数为{result}")