(E-Mail Removed) <(E-Mail Removed)> wrote:

> return fib(n-1)+fib(n-2);

> if I enter, say, 6, how does this class

> actually return 13?
Let's begin with 4 for the principle:

fib(4) will first calculate fib(3):

fib(3) will first calculate fib(2):

fib(2) will first calculate fib(1) which is 1

fib(2) will then calculate fib(0) which is also 1

fib(2) will then add 1 + 1 which gives 2

fib(3) will then calculate fib(1) which is 1

fib(3) will then add 2 + 1 which gives 3

fib(4) will then calculate fib(2):

fib(2) will first calculate fib(1) which is 1

fib(2) will then calculate fib(0) which is also 1

fib(2) will then add 1 + 1 which gives 2

fib(4) will then add 3 + 2 which gives 5

If you've understood that, doing it for 5 and then 6 is an

apt exercise for you.