diff --git a/04-fibonacci/index.js b/04-fibonacci/index.js index 37c64cc..7ef7188 100644 --- a/04-fibonacci/index.js +++ b/04-fibonacci/index.js @@ -1,4 +1,11 @@ export function fibonacci(value) { - // implementar logica aqui - -} \ No newline at end of file + 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; +}