From 0c2be2bced0763cea55e67324257f5cd91df5a92 Mon Sep 17 00:00:00 2001 From: ueberjames Date: Fri, 28 Oct 2022 20:34:14 -0300 Subject: [PATCH] =?UTF-8?q?feat:=20implementa=C3=A7=C3=A3o=20de=20algoritm?= =?UTF-8?q?o=20que=20resolva=20a=20fun=C3=A7=C3=A3o=20de=20Fibonacci.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 04-fibonacci/index.js | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/04-fibonacci/index.js b/04-fibonacci/index.js index 37c64cc..2c20083 100644 --- a/04-fibonacci/index.js +++ b/04-fibonacci/index.js @@ -1,4 +1,21 @@ export function fibonacci(value) { // implementar logica aqui + -} \ No newline at end of file + + + var termo = value; + var penultimo=0, ultimo=1; + var numero; + + if(termo<2) + numero = termo; + else + for(var count = 2 ; count <= termo ; count++){ + numero = ultimo + penultimo; + penultimo = ultimo; + ultimo = numero; + } + return numero + + } \ No newline at end of file