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

13 lines
263 B
JavaScript
Raw Normal View History

export function fibonacci(value) {
// implementar logica aqui
let first = 0;
let second = 1;
if (value <= 1) {
return value;
}
for(let i = 3; i <= value; i++){
second = first + second;
first = second - first;
}
return first + second;
}