You have to use yourself as a
debugger.
Let's make together just the first steps, starting from
main
, of course, we have:
int a = fn(4);
In order to assign the correct value to
a
we have to evaluate
fn(4)
.
So, let's
step into fn(4)
:
- We can safely ignore the
cout
line. - The
if
condition evaluates to false, since 4
is neither 0
nor 1
. - Eventually we reach the line
return fn(3) + fn(2);
This tell us we have to step again (and again) into fn
, with different argument values, in order to know our final result.
I suppose it is enough to make you figure out how to complete the homework.