forked from M3-Academy/challenge-algorithms-v2.0
feat(04-fibonacci):completead fourth challenge
This commit is contained in:
parent
c6f6df9c59
commit
4552cc3b13
@ -1,4 +1,10 @@
|
|||||||
export function fibonacci(value) {
|
export function fibonacci(value) {
|
||||||
// implementar logica aqui
|
// 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;
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user