From 87fcfe2d070c77034c1eac7ced9e2f711b97c1f7 Mon Sep 17 00:00:00 2001 From: Gustavo_Rallenson Date: Tue, 1 Nov 2022 21:48:16 -0300 Subject: [PATCH] fix:Ajuste de perfomace Fibonnaci --- 04-fibonacci/index.js | 11 +++++++---- 05-isPrime/index.js | 1 + 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/04-fibonacci/index.js b/04-fibonacci/index.js index 51e44d5..221d51b 100644 --- a/04-fibonacci/index.js +++ b/04-fibonacci/index.js @@ -1,7 +1,10 @@ export function fibonacci(value) { // implementar logica aqui - if (value <= 1) { - return value; -} -return fibonacci(value -1 ) + fibonacci(value -2) + const fib = [0,1] + let i = 1 + while (value > fib.length-1){ + fib.push(fib[i - 1] + fib[i]) + i ++ + } + return fib[value] } \ No newline at end of file diff --git a/05-isPrime/index.js b/05-isPrime/index.js index ad1c382..06b1567 100644 --- a/05-isPrime/index.js +++ b/05-isPrime/index.js @@ -1,5 +1,6 @@ export function isPrime(value) { // implementar logica aqui + if(value === 1){ return false }else{