递归的三个小代码
阶乘
def factorial(n):
if n == 1:
return n
else:
return n * factorial(n - 1)
求x的y次幂
def power(x, y):
if y == 1:
return x
else:
return x * power(x, y - 1)
求最大公约数
def gcd(x, y):
if y == 0:
return x
else:
return gcd(y, x % y)
递归好难啊!!!!!!