python: practice recurse function
Posted alansuny
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python: practice recurse function相关的知识,希望对你有一定的参考价值。
starting with a factorial :
def function_factorial(n):
number=1
for i in range(1,n+1):
number *=i
return number
print(function_factorial( n)
use this application can acheved one number‘s factorial.
similar recurse function also can realized one number factorial:
def function_recurse(n):
if n==1:
return 1
return n*function_recurse(n-1)
print(function_recurse(n))
recurse function have follow characters:
1:in itself‘s function call itself realize it function performance
2:must setup a broke point ,otherwise it will enter a endless loop.
3: all recurse function can realize function loop also can do .
4:recurse productive low efficiency,workpiece ratio inefficiency
以上是关于python: practice recurse function的主要内容,如果未能解决你的问题,请参考以下文章
hausaufgabe--python 22- Recurse
python Python中的Tail-Recursion助手