feat(fibonacci): Adiciona a logica do algoritmo que resolve a função de Fibonacci

This commit is contained in:
Amanda de Almeida Fonseca 2022-10-28 15:27:34 -03:00
parent 8aa3869a4f
commit 6c3fdd70b2

View File

@ -1,4 +1,14 @@
export function fibonacci(value) {
// implementar logica aqui
let fibM = value;
let fibMinus1 = 0;
let fibMinus2 = 1;
for (let i = 0; i < value; i++) {
fibM = fibMinus1 + fibMinus2;
fibMinus1 = fibMinus2;
fibMinus2 = fibM;
}
return fibMinus1
}