Este codigo funciona pruebalo:
let cont = 0;
let cache = [0,1,1];
let res = 0;
function fibo(num) {
if(!cache[num])
cache[num] = fibo(num - 1) + fibo(num - 2);
console.log(cache);
return cache[num]
}
function sequence(num) {
while(res != num) {
cont++;
res = fibo(cont);
}
return cont+1;
}
console.log(sequence(1597));