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

13 lines
255 B
JavaScript
Raw Normal View History

export function fibonacci(value) {
// implementar logica aqui
2022-10-29 05:04:11 +00:00
let soma = 0;
let anterior = 0;
let proximo = 1;
2022-10-28 21:26:51 +00:00
2022-10-29 05:04:11 +00:00
for (let i = 0; i < value; i++) {
soma = anterior + proximo;
anterior = proximo;
proximo = soma;
}
return anterior;
}