diff --git a/04-fibonacci/index.js b/04-fibonacci/index.js index 37c64cc..e4dd408 100644 --- a/04-fibonacci/index.js +++ b/04-fibonacci/index.js @@ -1,4 +1,10 @@ export function fibonacci(value) { // implementar logica aqui - + if(value < 0) return 0; + if(value < 2) return value; + if(memo[value]) return memo[value]; + let result = fibonacci(value - 1, memo) + fibonacci(value - 2, memo); + memo[value] = result; + console.log(memo); + return result; } \ No newline at end of file