forked from M3-Academy/challenge-algorithms-v2.0
dev #1
@ -2,13 +2,13 @@ export function fibonacci(value) {
|
|||||||
// implementar logica aqui
|
// implementar logica aqui
|
||||||
if (value < 1) return 0
|
if (value < 1) return 0
|
||||||
if (value <= 2) return 1
|
if (value <= 2) return 1
|
||||||
let fibMinus2 = 0
|
let fibAnterior = 0
|
||||||
let fibMinus1 = 1
|
let fibProximo = 1
|
||||||
let fibN = value
|
let fibValue = value
|
||||||
for(let i = 2; i <= value; i++){
|
for(let i = 2; i <= value; i++){
|
||||||
fibN = fibMinus1 + fibMinus2
|
fibValue = fibProximo + fibAnterior
|
||||||
fibMinus2 = fibMinus1
|
fibAnterior = fibProximo
|
||||||
fibMinus1 = fibN
|
fibProximo = fibValue
|
||||||
}
|
}
|
||||||
return fibN
|
return fibValue
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user