% isp(P) :- P is a prime number % (integer) (+) % the =:= operator evaluates both sides, and tests for % numerical equality % 1+4 =:= 3+2 % will work like this % comp(M,N) :- L is M, R is N, L=R. % comp(1+4,2+3). % % the =\= operator is similar, but tests for inequality isp(2). isp(3). isp(P) :- integer(P), P > 3, P mod 2 =\= 0, \+ has_factor(P,3). % has_factor(N,L) :- N has an odd factor F >= L. % (integer, integer) (+,+) has_factor(N,L) :- N mod L =:= 0. has_factor(N,L) :- L*L