Home > Back-end >  Help newcomers, a function with two recursive call, the calling process will be what kind of
Help newcomers, a function with two recursive call, the calling process will be what kind of

Time:03-23

The problem is I really want to head all can't think of recursive calls

/* following a given program, the function fun () function is: using a recursive algorithm to calculate the Fijian Paula series the n items of value in a column,
Since the first item, Fibonacci ratched,1,2,3,5,8,13,21 series sequence is 1,... If, for example, to the n input 7
Grade, the Fibonacci ratched numerical as 13, */
#include Long fun (int g)
{
The switch (g)
{
Case 0:
return 0;
Case 1: case 2://case: statements will directly through the next statement
return 1;
}
Return (fun) (g - 1) + (fun (g - 2));//recursive algorithm
}

Int main ()
{
Long fib. int n;
Printf (" Input n: ");
The scanf (" % d ", & amp; N);
Printf (" n=% d \ n ", n);
Fib=fun (n);
Printf (" fib=% d \ n \ n ", fib).
}
  • Related