Prolog Program To Check If A Number Is Prime
问题 I wrote the following program based on the logic that a prime number is only divisible by 1 and itself. So I just go through the process of dividing it to all numbers that are greater than one and less than itself, but I seem to have a problem since I get all entered numbers as true. Here's my code... divisible(X,Y) :- Y < X, X mod Y is 0, Y1 is Y+1, divisible(X,Y1). isprime(X) :- integer(X), X > 1, \+ divisible(X,2). Thanks in advance :) 回答1: I'm a beginner in Prolog but managed to fix your