fork(1) download
  1. #include <stdio.h>
  2. int count=0;
  3.  
  4. double foo(int n)
  5. { count++;
  6. int i;
  7. double sum;
  8. if(n == 0)
  9. {
  10.  
  11. return 1.0;
  12. }
  13. else
  14. { sum = 0.0;
  15. for(i = 0; i < n; i++)
  16. {
  17.  
  18. sum += foo(i);
  19. }
  20. return sum;
  21. }
  22.  
  23. }
  24.  
  25. int main(void) {
  26. double r;
  27. r=foo(5);
  28. printf("Value of foo(5) is %lf\n",r);
  29. printf("\n Function Called %d times for foo(5) ",count);
  30.  
  31. return 0;
  32. }
  33.  
Success #stdin #stdout 0s 9424KB
stdin
Standard input is empty
stdout
Value of foo(5) is 16.000000

 Function Called 32 times for foo(5)