下面这段程序的功能是什么?( )
def f(a, b): if b == 0: return a else: return f(b, a%b) a, b = input(“Enter two natural numbers: ”) print f(a, b)
def f(a, b): if b == 0: return a else: return f(b, a%b) a, b = input('Enter two natural numbers: ').split() print(f(int(a), int(b)))
def f(a, b): if b == 0: return a else: # print(f(b,a%b)) return f(b, a % b) # a, b = input('Enter two natural numbers: ') a = int(input('Enter natural numbers: ')) b = int(input('Enter natural numbers: ')) print(f(a, b))输入a=24,b=6,进入循环,b≠0,else,返回a=b=6,b=a%b=0;再次进入循环,b=0,返回a. a=6. 相对于两者最大公因数