Merge branch 'feature/fibonacci' into development

This commit is contained in:
Marcello Rodrigues Martins 2022-10-31 18:42:13 -03:00
commit 234cd1a798

View File

@ -1,10 +1,9 @@
export function fibonacci(value) { export function fibonacci(value,memo = {}) {
// implementar logica aqui // implementar logica aqui
if(value < 0) return 0; if(value < 0) return 0;
if(value < 2) return value; if(value < 2) return value;
if(memo[value]) return memo[value]; if(memo[value]) return memo[value];
let result = fibonacci(value - 1, memo) + fibonacci(value - 2, memo); let result = fibonacci(value - 1, memo) + fibonacci(value - 2, memo);
memo[value] = result; memo[value] = result;
console.log(memo);
return result; return result;
} }