#欧几里得算法 def myfun(x,y): if x % y == 0: return y else: temp = y y = x % y x = temp return myfun(x,y) num1 = int(input("请输入x:")) num2 = int(input("请输入y:")) result = myfun(num1,num2) print("%d与%d的最大公约数是%d" % (num1,num2,result))
def gcd(x, y): if y: return gcd(y, x%y) else: return x print(gcd(4, 6))