title: What is a practical difference between a loop and recursion
body: <p>I am currently working in PHP, so this example will be in PHP, but the question applies to multiple languages.</p>
  
  <p>I am working on this project with a fiend of mine, and as always we were held up by a big problem. Now we both went home, couldn't solve the problem. That night we both found the solution, only I used a loop to tackle the problem, and he used recursion.</p>
  
  <p>Now I wanted to tell him the difference between the loop and recursion, but I couldn't come up with a solution where you need recursion over a normal loop.</p>
  
  <p>I am going to make a simplified version of both, I hope someone can explain how one is different from the other.</p>
  
  <p><em>Please forgive me for any coding errors</em></p>
  
  <p>The loop:</p>
  
  <pre><code>printnumbers(1,10);
  
  public function printnumbers($start,$stop)
  {
      for($i=$start;$i&lt;=$stop;$i++)
      {
          echo $i;
      }
  }
  </code></pre>
  
  <p>Now the code above just simply prints out the numbers.</p>
  
  <p>Now let's do this with recursion:</p>
  
  <pre><code>printnumbers(1,10);
  
  public function printnumbers($start,$stop)
  {
      $i = $start;
      if($i &lt;= $stop)
      {
          echo $i;
          printnumbers($start+1,$stop);
      }
  }
  </code></pre>
  
  <p>This method above will do the exact same thing as the loop, but then only with recursion.</p>
  
  <p>Can anyone explain to me what there is different about using one of these methods.</p>