# Basic primality test predicate in Prolog

Advertisements I am trying to create a predicate isPrime/1 that checks if a given number is prime or not. I have come up with the following code: primeRec(_, 2). primeRec(X, Y) :- Y > 2, X mod Y-1 > 0, primeRec(X, Y-1). isPrime(2). isPrime(X) :- X > 1, X mod 2 > 0, primeRec(X, X).… Read More Basic primality test predicate in Prolog