如何用循环??
如下:
inp = input('请输入两个值(以空格隔开):').split()
a = int(inp[0])
b = int(inp[1])
x = a%b
while True:
if x != 0:
y = b%x
b = x
x = y
else:
print(inp[0] + ' ' + inp[1] + ' ' +str(b))
break
while
就是循环,他的条件是找到最大公约数
import re
n,m=map(int,re.findall('[\d]+',input("请输入两个数,用空格隔开")))
_n=n
_m=m
while _m:
_n,_m=_m,_n%_m
print(n,m,_n)