can someone explain this to me

can someone explain me this is different terms

Write a program that will trace how Fibonacci numbers are generated recursively (for any N) and display the trace in the following way :

Example (N=4):

Entering level 0
-----Entering level 2
-------------Entering level 4
-------------Exiting level 4
----------Entering level 3
----------Exiting level 3
------Exiting level 2
----Entering level 1
----------Entering level 3
----------Exiting level 3
------Entering level 2
-------------Entering level 4
-------------Exiting level 4
----------Entering level 3
----------Exiting level 3
------Exiting level 2
----Exiting level 1
Exiting level 0

Last edited on
can you past your code here ..
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
int fib(int n)
{
  if(1 == n || 2 == n)
  {
      return 1;
  }
  else
  {
      return fib(n-1) + fib(n-2);
  }

}

int main()
{
    for(int i=1; i<=10; i++)
    {
        cout << fib(i) << endl;
    }
    
    system("PAUSE");
    return 0;
}


thats what i have so far
Last edited on
Topic archived. No new replies allowed.