From bfdc5780442612ebbbc4cb4778102654fbec73d7 Mon Sep 17 00:00:00 2001 From: vitorsoaresdev Date: Fri, 28 Oct 2022 11:49:25 -0300 Subject: [PATCH] feat: finalizado fibonacci --- 04-fibonacci/index.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/04-fibonacci/index.js b/04-fibonacci/index.js index 37c64cc..f764b91 100644 --- a/04-fibonacci/index.js +++ b/04-fibonacci/index.js @@ -1,4 +1,15 @@ export function fibonacci(value) { // implementar logica aqui + let n1 = 0 + let n2 = 1 + let fibo + + for (let i = 1; i <= value; i++) { + fibo = n1 + n2; + n1 = n2; + n2 = fibo; + }; + + return n1 } \ No newline at end of file