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

11 lines
242 B
JavaScript
Raw Normal View History

export function fibonacci(value) {
// implementar logica aqui
2022-10-29 19:48:49 +00:00
const sequence = [0, 1];
for (let i = 2; i <= value; i++) {
sequence[i] = sequence[i - 2] + sequence[i - 1];
}
return sequence[value];
}
fibonacci(0) // 0