title: A Prolog code to generate prime numbers from 1 to N
body: <p>I've been trying to do a Prolog problem to generate the prime numbers from 1 to N but it keeps  replying with true or false and i cannot find the error.
  Query example: generatePrime(10, X)</p>
  
  <pre><code>isPrime( 2 ) .
  isPrime( P ) :-
    P &gt; 2 ,
    isDivisible( P , P-1 ) .
  
  isDivisible( P , X ) :-
    X &gt; 1,
    P mod X =\= 0 ,
    isDivisible( P , X-1 ) .
  isDivisible( _ , X ) :-
    1 is X .
  
  generatePrime( N , X ) :-
    not( isPrime( N ) ) ,
    Z is N-1 ,
    generatePrime( Z , X ) .
  generatePrime(N, X):-
    isPrime( N ) ,
    X is N ,
    Z is N-1 ,
    generatePrime( Z , X ) .
  generatePrime( 1 , X ) :-
    X is 1 .
  </code></pre>