int fib (int n)
{
if (n <= 1) return 1;
return fib (n-1) + fib (n-2);
}
Wouldn't it be nice to see how computer will proceed through stack to return the correct number?
I did it for you. We are starting at green box calculating value of 5th element. Have fun!
Function flow |
No comments:
Post a Comment