challenge-algorithms-v2.0-J.../04-fibonacci/index.js

13 lines
265 B
JavaScript
Raw Normal View History

export function fibonacci(value) {
// implementar logica aqui
2022-10-29 02:46:08 +00:00
let fibo = [];
let i = 0;
for (i = 0 ; i <= value; i++) {
if (i < 2)
fibo[i] = i;
else
fibo[i] = fibo[i-1] + fibo[i-2];
}
return fibo[value];
}