forked from M3-Academy/challenge-algorithms-v2.0
14 lines
336 B
JavaScript
14 lines
336 B
JavaScript
export function fibonacci(value) {
|
|
// implementar logica aqui
|
|
if (value < 1) return 0
|
|
if (value <= 2) return 1
|
|
let fibAnterior = 0
|
|
let fibProximo = 1
|
|
let fibValue = value
|
|
for(let i = 2; i <= value; i++){
|
|
fibValue = fibProximo + fibAnterior
|
|
fibAnterior = fibProximo
|
|
fibProximo = fibValue
|
|
}
|
|
return fibValue
|
|
} |