Last active: 3 years ago
Fibonacci
function fibonacci(num) {
let count = 0;
let result = [1, 1];
if (num <= 1) {
return result;
}
let n = num - 2;
for (let i = 0; i < n; i++) {
result.push(result[count] + result[count + 1]);
count++;
}
return result;
// let rs = result.reduce((a, b) => a + b);
// return rs;
}