title: How to understand function recursion precisely?
body: <p>I am currently programming some divide-conquer algorithms, where function recursions are used everywhere, but I have very vague idea or no idea how exactly it works, and that's why I post it here and hope you don't mind it's too basic.</p>
  
  <p>For example, if we have the following code:</p>
  
  <pre><code>#include&lt;iostream&gt;
  using namespace std;
  void Recursion(int n)
  {
    cout &lt;&lt; n &lt;&lt; endl;
    if(n &gt; 0)
    {
      Recursion(n-1);
    }
    cout&lt;&lt;n&lt;&lt;endl;
  }
  
  int main()
  {
    Recursion(3);
    return 0;
  }
  </code></pre>
  
  <p>I tested Recursion(3) and the print out in the terminal is:</p>
  
  <pre><code>3
  2
  1
  0
  0
  1
  2
  3
  </code></pre>
  
  <p>I can understand the concept of recursive call of the function but I don't understand the mechenism how it works. For example, what will they do after they can't call the function again? For example, here, I can understand it prints from 3 to 0 but why it also prints from 0 to 3 again? I heard it's because function recursion is stored in a stack for one recursion and when it reaches the "bottom" it also has to delete.</p>
  
  <p>But anyway, I don't know about it. So, can anyone help me out and clearly tell me what happened here and the exact flow of function call?</p>
  
  <p>Thanks for your help!</p>