标签:
函数:
def fact(n):
if n==1:
return 1
return n * fact(n-1)
递归过程:
print(fact(5))
>>fact(5)
>>5 * fact (4)
>>5 * (4 * fact(3))
>>5 * (4 * (3 * fact(2)))
>>5 * (4 * (3 * (2 * fact(1))))
>>5 * (4 * (3 * (2 * 1)))
>>5 * (4 * (3 * 2))
>>5 * (4 * 6)
>>5 * 24
>>120
标签:
原文地址:http://www.cnblogs.com/hujianping/p/4582570.html