'-Define a predicate to display all multiples of

i have ERROR in this code in prolog can you help me?

div(X):- X mod 3 =:= 0.


Solution 1:[1]

div(X):- X mod 3 =:= 0 ...
div(X):- X mod 3 =:=1  ...

2 mod 3 is not 0 or 1, so there is no way to do div(2), so it fails.

Maybe you wanted

X mod 3 =:= 0    % remainder 0
X mod 3 =\= 0    % remainder not 0

?

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 TessellatingHeckler