title: Number of additions in a recursive function without using global variables in c++
body: <p>I have to implement a counter that counts the number of additions in this recursive function, but i am not allowed to use global variables. Do you know how to do that? For example if the function has to call itself free times then my counter has to be put on three at the end of the function just before the return.  </p>
  
  <pre><code>long lindh(unsigned int n) {
  
    long lin = 0;
    if (n == 1 || n == 2) {
      lin = 1;
    } else {
      lin = 1 * lindh(n - 1) + 3 * lindh(n - 2);
    }
  
    return lin;
  }
  
  int main() {
    long b = 0;
    b = lindh(24);
  
    cout &lt;&lt; "lindhauer " &lt;&lt; b &lt;&lt; endl;
  
    return 0;
  }
  </code></pre>