I am total lost on this

``````var count = 0;

// Recursively find Xth Fibonacci number
var fib = function(x){
// Keeps track of the amount of work done computing a Fibonacci
count++;

// Base Case
if(x < 2  ) { return 1; }

// Recursive calls
return fib( count );    fib(count);
};

var f = fib(10);
console.log("It took "+count+" calculations to find that the 10th fibonacci number is "+f+".");
``````

I found your problem! All you have to do is take away the fib(count); from after the return function!

``````// here is the finished code
var count = 0;
// Recursively find Xth Fibonacci number
var fib = function(x){
// Keeps track of the amount of work done computing a Fibonacci
count++;

// Base Case
if(x < 2  ) { return 1; }

// Recursive calls
return fib( count );
};

var f = fib(10);
console.log("It took "+count+" calculations to find that the 10th fibonacci number is "+f+".");
``````

Hope this helped!

ps3 over 5 years ago

Awsomeeeee Thank you so much!!!!!!

Tatjana Seketa over 5 years ago

William Platt almost 5 years ago

That's not right, count is just used to see how efficient the function is (as the comments say); you're not supposed to use it in the function (other than incrementing it). Your method will always call `fib(1)` in the recursive case, then return 1. The recursive case should actually be `return fib(x - 1) + fib(x - 2);`.

``````return fib(x-1) + fib(x-2)