Prolog problem

View: New views
1 Messages — Rating Filter:   Alert me  

Prolog problem

by hFOUr :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hey everybody,
what I need to do is to make predicate magic(S,X,Y) all pairs of 2 numbers X Y that:
(X + Y) + (X - Y) + (X*Y) + (X / Y) = S (S <= 3000)
For example: S = 243 so then X = 24, Y = 8.

I made this:
magic(S,X,Y) :- X > Y, S is X+Y+(X-Y)+X*Y+(X div Y),between(1,3000,S).
magic(S,X,Y) :- Y > X, S is X+Y+(Y-X)+X*Y+(X div Y),between(1,3000,S).

But I always get this error msg:
ERROR: toplevel: Undefined procedure: magic/3 (DWIM could not correct goal)

Can any1 help? Thanks