feat: criação da resposat do 04-fibonacci

This commit is contained in:
Matheus Mariosa 2022-11-02 11:46:38 -03:00
parent aab21161ae
commit 8947b76351

View File

@ -1,4 +1,17 @@
export function fibonacci(value) { export function fibonacci(value) {
// implementar logica aqui // implementar logica aqui
let number1 = 0;
let number2 = 1;
let result;
if (value === 0 || value === 1 ) {
return value;
} else {
for (let i = 1 ; i < value ; i++) {
result = number2 + number1;
number1 = number2;
number2 = result;
}
}
return result;
} }