首页 > 代码库 > 尾递归

尾递归

http://www.liaoxuefeng.com/wiki/001374738125095c955c1e6d8bb493182103fac9270762a000/00137473836826348026db722d9435483fa38c137b7e685000

 

尾递归是 递归的一种

>>> def fact(n):	return fact_iter(0,1,n)>>> def fact_iter(product,counter,max):	if counter>max:		return product	return fact_iter(product+counter,counter+1,max)>>> fact(2)3

  

尾递归