also, cannot understand how
Code:
return fibb(x-2) + fibb(x-3);
is evaluated.
It starts calling itself in fibb(x-2), but what the addition of the 2 function calls mean?
It is a tricky test question, from a test preparation samples and I cannot get it.
My guess: // total of 5 calls only
1. fibb(7-2) = 5
2. fibb(5-2) = 3
3. fibb(3-2) = 1, 1<3, return 1;
// does it start to evaluate fibb(x-3) now?
.....
6. fibb(7-3) = 4
....
8. fibb(4-3) = 1, 1<3, return 1;
But there are some strange extra calls:
Code:
4.call: fib(0)
returns 1
5.call: fib(2)
returns 1
7.call: fib(2)
returns 1