From c7af3bfd17cc0f902e3deae6d237574896660599 Mon Sep 17 00:00:00 2001 From: Victor Souza Date: Mon, 31 Oct 2022 16:34:44 -0300 Subject: [PATCH] feat(fibonacci):adicionando funcionalidade --- 04-fibonacci/index.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/04-fibonacci/index.js b/04-fibonacci/index.js index 37c64cc..8d2664e 100644 --- a/04-fibonacci/index.js +++ b/04-fibonacci/index.js @@ -1,4 +1,13 @@ export function fibonacci(value) { - // implementar logica aqui - + let add = 0 + let previousValue = 0 + let nextValue = 1 + + for (let i = 0; i < value; i++) { + add = previousValue + nextValue; + previousValue = nextValue; + nextValue = add; + } + return previousValue + } \ No newline at end of file