目录
- 一、Create New Project
- 1.1 the rules of name
- 二、hugeng007_01_tail recursion
- 2.1 Conventional Recursive Factorial
- 三、The Unknown Word
一、Create New Project
1.1 the rules of name
- hugeng007_xx(number)_name
二、hugeng007_01_tail recursion
2.1 Conventional Recursive Factorial
def factorial(n):
if n==0:
return 1
return factorial(n-1)*n
- Execution Process:
f(4)=f(3)*4
f(3)=f(2)*3
f(2)=f(1)*2
f(1)=1
- the result of execution
f(4)=1*2*3*4
2.2 tail recursion
def factorial(n,acc=1):
if n==0:
return acc
return factorial(n-1,n*acc)
三、The Unknown Word
The First Column | The Second Column |
---|---|
tail | [tel]尾部 |
recursion | 递归[ri‘kesion] |
factorial | 阶乘 |
acc | accumulation 叠加器 |
原文地址:https://www.cnblogs.com/hugeng007/p/9362833.html
时间: 2024-10-11 08:00:52