题解 | #斐波那契数列#
斐波那契数列
http://www.nowcoder.com/practice/c6c7742f5ba7442aada113136ddea0c3
function Fibonacci(n)
{
n = parseInt(n);
if (n < 2) {
return 1;
} else {
let arr = new Array(n).fill(1);
for (let i= 2; i<n; i++) {
arr[i] = arr[i-1] + arr[i-2];
}
return arr[n -1];
}
}
module.exports = {
Fibonacci : Fibonacci
};