python 递归函数

def factoria(n):
    if n == 1:
        return 1
    else:
        return n * factoria(n-1)

def power(x,n):
    if n == 0:
        return 1
    else:
        return x * power(x, n-1)

print(factoria(5))
print(power(3,3))

result:

 

120
27

  

posted @ 2019-06-25 10:09  嵌入式实操  阅读(155)  评论(0编辑  收藏  举报