Open ChenPt opened 6 years ago
阶乘递归实现
let factorial = (num) => {
if(num === 1) return 1
return num * factorial(num-1)
}
阶乘迭代实现
let factorial2 = (num) => {
let res = 1
for(let i = 1; i <= num; i++) {
res = i * res
}
return res
}
斐波那契数列
迭代实现
let fib1 = () => {
}