title: Prolog - print the sum of the EVEN numbers from 1 to 10
body: <p>I am trying to print all the even numbers from 1 to 10 using Prolog, and here is what I have tried: </p>
  
  <pre><code>printn(10,0):- write(10),!.
  printn(X,Sum):- 
      ( X mod 2 =:= 0 -&gt; Sum is X+Sum, Next is X+1, nl, printn(Next);
        Next is X+1, printn(Next) ).
  </code></pre>
  
  <p>but it returns false. </p>