feat: Algoritmo 04-fibonacci - finalizado

This commit is contained in:
José Carlos Lins 2022-10-27 20:10:47 -03:00
parent 753a4a9c77
commit a55909d38f

View File

@ -1,4 +1,20 @@
export function fibonacci(value) {
// implementar logica aqui
let fibMenor1 = 0;
let fibMenor2 = 1;
let fibN = 0;
if(value < 2){
return value;
}
for (let i = 1; i <= value; i++){
fibN = fibMenor1 + fibMenor2;
fibMenor2 = fibMenor1;
fibMenor1 = fibN;
}
return fibN;
}