// 递归
function fibRecursion(n=10) {
var _fn = (a,b,n)=>{
if (n == 0) {
return a
}
console.log(a)
return _fn(b, a + b, n - 1)
}
return _fn(0, 1, n)
}
fibRecursion()
// 循环
function fibLoop(n=10) {
var a = 0
, b = 1
while (n > 0) {
console.log(a)
var c = a + b // 需要缓存两个数相加的值
a = b
b = c
n--
}
return a
}
fibLoop()