title: understanding basic recursion
body: <pre><code>public static void main (String[] args)
  {
      System.out.println(factorial(5));
  }
  
  public int factorial(int n)
  {
      if(n &lt;= 1){
          return 1;
      }
      else{
          return n * factorial(n - 1);
      }
  }
  </code></pre>
  
  <p>I wrote the above directly in here so may not compile but think it does.</p>
  
  <p>Can anyone breiefly explain how this works in the sence that how is it stored? It starts off by calculating 5 * (5-1), then down to 4 * (4-1) then 3 * (3-1)..... until it gets to 1 which will just return 1 right? sorry for being so sketchy i would just be interested to find out how 
  this works exactly </p>
  
  <p>thanks </p>
  
  <p>but as it works it out - it gets the values for the individual stages </p>
  
  <p>5*(5-1)
  4 * (4-1)
  ...
  ...
  ...</p>
  
  <p>how are these stored and then retrieved back or am i missing something?</p>