From 8947b7635126ceb44fdb9b386a611f27d5c343aa Mon Sep 17 00:00:00 2001 From: Matheus Date: Wed, 2 Nov 2022 11:46:38 -0300 Subject: [PATCH] =?UTF-8?q?feat:=20cria=C3=A7=C3=A3o=20da=20resposat=20do?= =?UTF-8?q?=2004-fibonacci?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 04-fibonacci/index.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/04-fibonacci/index.js b/04-fibonacci/index.js index 37c64cc..976c078 100644 --- a/04-fibonacci/index.js +++ b/04-fibonacci/index.js @@ -1,4 +1,17 @@ export function fibonacci(value) { // implementar logica aqui - + let number1 = 0; + let number2 = 1; + let result; + + if (value === 0 || value === 1 ) { + return value; + } else { + for (let i = 1 ; i < value ; i++) { + result = number2 + number1; + number1 = number2; + number2 = result; + } + } + return result; } \ No newline at end of file