challenge-algorithms-v2.0-n.../04-fibonacci/index.js

15 lines
228 B
JavaScript

export function fibonacci(value) {
// implementar logica aqui
let val1 = 0
let val2 = 1
let valFib
for (let i = 1; i <= value; i++){
valFib = val2 + val1
val1 = val2
val2 = valFib
}
return val1
}