title: How does recursive algorithm work for Towers of Hanoi?
body: <p>This is code from a book I have explaining recursion. The problem is that I don't understand the steps taken by the program:</p>
  
  <pre><code>var hanoi = function(disc,src,aux,dst) {
      if (disc &gt; 0) {
          hanoi(disc - 1,src,dst,aux);
          document.write("Move disc " + disc + " from " + src + " to " + dst + "&lt;br /&gt;");
          hanoi(disc - 1,aux,src,dst);
      }
  };
  
  hanoi(3,"src","aux","dst");
  </code></pre>
  
  <p>This is how the Output reads:</p>
  
  <pre><code>Move disc 1 from src to dst
  Move disc 2 from src to aux
  Move disc 1 from dst to aux
  Move disc 3 from src to dst
  Move disc 1 from aux to src
  Move disc 2 from aux to dst
  Move disc 1 from src to dst
  </code></pre>
  
  <p>Can someone break this down step by step? It would be very helpful to me.</p>