有更好的解法各位大大可以在下面回復
a=(input().split())
b=a[0]
c=a[1]
d=int(b)
e=int(c)
while d%e !=0 and e%d !=0:
if (d==e):
print(str(d))
elif (d>e):
if d%e==0:
print(str(e))
else:
d=d%e
else:
if e%d==0:
print(str(d))
else:
e=e%d
if d<=e:
print(str(d))
else:
print(str(e))
有更好的解法各位大大可以在下面回復
a=(input().split())
b=a[0]
c=a[1]
d=int(b)
e=int(c)
while d%e !=0 and e%d !=0:
if (d==e):
print(str(d))
elif (d>e):
if d%e==0:
print(str(e))
else:
d=d%e
else:
if e%d==0:
print(str(d))
else:
e=e%d
if d<=e:
print(str(d))
else:
print(str(e))
def GCD(a,b):
if a%b==0:
return b
else:
return GCD(b,a%b)
a,b = (input().split())
print(GCD(int(a),int(b)))
👍