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

8 lines
203 B
JavaScript

export function fibonacci(value) {
// implementar logica aqui
let arr = [ 0, 1 ];
for (let i = 2; i < value + 1; i++) {
arr.push ( arr [ i - 2 ] + arr [ i - 1 ] )
}
return arr [ value ]
}