title: Prolog factorial recursion
body: <p>I'm having trouble understanding the following factorial program</p>
  
  <pre><code>fact1(0,Result) :-
      Result is 1.
  fact1(N,Result) :-
      N &gt; 0,
      N1 is N-1,
      fact1(N1,Result1),
      Result is Result1*N.
  </code></pre>
  
  <p>When <code>fact1</code> is called nested within the second <code>fact1</code>, doesn't that mean that the the last line, <code>Result is Result1*N.</code>, is never called? Or in Prolog does the last line get executed before the recursive call?</p>