python的循环的问题的解决

img

如何用循环??

如下:

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

img

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)

img

有帮助请采纳,有问题继续交流,你的采纳是对我回答的最大的肯定和动力