title: Counting recursive function calls which are a multiple of k in C
body: <p>The assignment was to create a program that computes the Ackermann equation using recursion, which I successfully did. Part of the assignment says: </p>
  
  <p><em>"The function should print the number of recursive function calls which are multiple of k. Set k = 100 for
  values of n; m &lt;= 3, and k = 1; 000; 000 for all other values. Your program should also print the total number
  of function calls made."</em></p>
  
  <p>The <em>ackermann</em> function is supposed to print out the number of function calls and recursive functions calls, but I can't figure out how to do it. Any help would be great. Thanks!</p>
  
  <p>This is what I have so far:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  //function to compute the end result ackermann equation
  int ackermann (int n, int m)
  {
      int result = 0;
  
      if (n == 0)
      {
          result = m + 1;
  
      } else if (m == 0)
      {
          result = ackermann(n - 1, 1);
  
      } else
      {
          result = ackermann(n - 1, ackermann(n, m - 1));
      }
  
      return result;
  }
  
  //main function
  int main(int argc, const char * argv[])
  {
      char ans = 'y';
      int m, n, result;
  
      printf("\n\n------Ackermann Function------");
  
      while (ans == 'Y' || ans == 'y') {
          printf("\nPlease enter n: ");
          scanf("%d", &amp;n);
  
          printf("\nPlease enter m: ");
          scanf("%d", &amp;m);
  
          result = ackermann(n, m);
  
          printf("\nResult: %d", result);
  
          printf("\n\nDo you want to go again? ");
          scanf(" %c", &amp;ans);
      }
  
      return 0;
  }
  </code></pre>