title: Beginner - add multiples of 3 and 5
body: <p>I'm trying to find the sum of all positive multiples of 3 and 5 below 1000. After adding the portion that's supposed to remove the multiples of 3 from the sum of the multiples of 5, gprolog will keep spitting out "No" for the query <code>?- sigma(1000,N).</code></p>
  
  <p>The problem apparently lies in sigma5, but I can't quite spot it:</p>
  
  <pre><code>sigma(Num, Result) :- sigma3(Num, 3, Result3),
                        sigma5(Num, 5, Result5),
                        Result is Result3 + Result5.
  
  sigma3(Num, A, Result) :- A &lt; Num,
                            Ax is A+3,
                            sigma3(Num, Ax, ResultX),
                            Result is ResultX + A.
  sigma3(Num, A, Result) :- A &gt;= Num,
                            Result is 0.
  
  sigma5(Num, A, Result) :- A &lt; Num,
                            mod3 is A mod 3,
                            0 \= mod3,
                            Ax is A+5,
                            sigma5(Num, Ax, ResultX),
                            Result is ResultX + A.
  sigma5(Num, A, Result) :- A &lt; Num,
                            mod3 is A mod 3,
                            0 == mod3,
                            Ax is A+5,
                            sigma5(Num, Ax, ResultX),
                            Result is ResultX.
  sigma5(Num, A, Result) :- A &gt;= Num,
                            Result is 0.
  </code></pre>
  
  <p>What's the problem with my code?</p>