From c4e8de1c150205ba4590aedb7b64dfcad183132c Mon Sep 17 00:00:00 2001 From: Affonsok Date: Sun, 30 Oct 2022 15:31:09 -0300 Subject: [PATCH] =?UTF-8?q?feat(fibonacci):=20Responde=20fun=C3=A7=C3=A3o?= =?UTF-8?q?=2004?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 04-fibonacci/index.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/04-fibonacci/index.js b/04-fibonacci/index.js index 716e088..5c82af6 100644 --- a/04-fibonacci/index.js +++ b/04-fibonacci/index.js @@ -1,4 +1,8 @@ export function fibonacci(value) { // implementar logica aqui - + let arr = [ 0, 1 ]; + for (let i = 2; i < value + 1; i++) { + arr.push ( arr [ i - 2 ] + arr [ i - 1 ] ) + } + return arr [ value ]; } \ No newline at end of file