feat(04): finished

This commit is contained in:
Matheus Brollo Dauter 2022-10-31 12:45:41 -03:00
parent 47142e3085
commit 433eb5906d

View File

@ -2,13 +2,13 @@ export function fibonacci(value) {
// implementar logica aqui
if (value < 1) return 0
if (value <= 2) return 1
let fibMinus2 = 0
let fibMinus1 = 1
let fibN = value
let fibAnterior = 0
let fibProximo = 1
let fibValue = value
for(let i = 2; i <= value; i++){
fibN = fibMinus1 + fibMinus2
fibMinus2 = fibMinus1
fibMinus1 = fibN
fibValue = fibProximo + fibAnterior
fibAnterior = fibProximo
fibProximo = fibValue
}
return fibN
return fibValue
}