From cfe0e803bfd43e7845d5482b7ef557a6e608aff0 Mon Sep 17 00:00:00 2001 From: danielmoliaribarbosa Date: Fri, 28 Oct 2022 14:57:41 -0300 Subject: [PATCH] =?UTF-8?q?feat(fibonacci):=20Implementa=20fun=C3=A7=C3=A3?= =?UTF-8?q?o=20fibonacci?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 04-fibonacci/index.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/04-fibonacci/index.js b/04-fibonacci/index.js index 37c64cc..fbd62d0 100644 --- a/04-fibonacci/index.js +++ b/04-fibonacci/index.js @@ -1,4 +1,13 @@ export function fibonacci(value) { // implementar logica aqui - + let first = 0; + let second = 1; + if (value <= 1) { + return value; + } + for(let i = 3; i <= value; i++){ + second = first + second; + first = second - first; + } + return first + second; } \ No newline at end of file