Reputation: 1175
I am analyzing the code of whether a number is prime or not i am not able to get the meaning of operator "\+" in prolog.(I am naive in prolog).
is_prime(2). is_prime(3).
is_prime(P) :- integer(P), P > 3, P mod 2 =\= 0, \+ has_factor(P,3).
has_factor(N,L) :- N mod L =:= 0.
has_factor(N,L) :- L * L < N, L2 is L + 2, has_factor(N,L2).
I have understand the other thing but not able to understand the meaning of "\+" in second line.
can anyone explain me the above?
Upvotes: 0
Views: 319
Reputation: 20520
It means "not provable". So \+ Thing
succeeds if Thing
can't be proven.
There's a useful dictionary of Prolog. The negation section is what you're after.
Upvotes: 1