title: Recursive - I cannot understand how it really works
body: <p>I can't understand something about the recursive function. Let's assume that i'm calculating the factorial of an x number. The code would look like this:</p>
  <pre><code>#include &lt;iostream&gt;
  using namespace std;
  
  int factorial(int y){
      if(y == 0)
          return 1;
      return y * factorial(y-1);
  
  
  }
  
  int main() {
      int n;
      cin &gt;&gt; n;
      cout &lt;&lt; factorial(n);
  
  
  
      return 0;
  }
  </code></pre>
  <p>And there, from my understanding, i have an base case, which will stop the function at one point. Good until now, after the base case, the next statement will return the x * factorial(x-1).
  Lets assume that we want to find the factorial of number &quot;4&quot;. It will look something like that:</p>
  <pre><code>x = 5 --&gt; x != 0, return 5 * factorial(4) | 
  x = 4 --&gt; x != 0, return 4 * factorial(3) | 
  x = 3 --&gt; x != 0, return 3 * factorial(2) |
  x = 2 --&gt; x != 0, return 2 * factorial(1) |
  x = 1 --&gt; x != 0, return 1 * factorial(0) |
  </code></pre>
  <p>And now, because x equals 0, the next statement will run:</p>
  <pre><code>if(x == 0)
    return 1;
  </code></pre>
  <p>What i don't understand:  if the function return 1, the program should return exactly the number &quot;1&quot;, why and how it return what was calculated on the recursive statement.</p>