add fibonacci logic

This commit is contained in:
Marcela Mathias 2022-11-02 16:54:41 -03:00
parent 3b2b27070b
commit c6379b5b4e

View File

@ -1,4 +1,11 @@
export function fibonacci(value) {
// implementar logica aqui
}
if (value == 0) return 0;
let firstValue = 0;
let secondValue = 1;
for (let i = 2; i <= value; i++) {
let newValue = firstValue;
firstValue = secondValue;
secondValue += newValue;
}
return secondValue;
}