title: How does order of precedence affect a recursive method?
body: <p>I'm interested in learning how the following recursive method handles it's return statement. Using the debugger it seems the method argument gets pushed to the stack. Then upon return the equation is evaluated. In the call tree below how are the values 1, 2, 6, and 24 generated?</p>
  
  <pre><code>factorial(5) 
     factorial(4) 
        factorial(3) 
           factorial(2) 
              factorial(1) 
                 return 1 
              return 2*1 = 2 
           return 3*2 = 6 
        return 4*6 = 24 
     return 5*24 = 120
  
    private static int factorial(int x)
      {
          if (x == 1)
              return 1;
          return x * factorial(x - 1);
      }
  </code></pre>