Without actually running it, looks infinite recursion as last predicate is same as lhs of the rule Put another variable there, same variable can not unify with two values (forget assignment same varible name means exactly same value in Prolog) actually thinking about it the last statement is junk, remove it. Only add ground rule when Y <= M
pyTony
pyMod
6,299 posts since Apr 2010
Reputation Points: 879
Solved Threads: 984
Skill Endorsements: 26
Basic logical definition of mod/3 is
mod(X, Y, X) :- X < Y.
mod(X, Y, Z) :- plus(X1, Y, X), mod(X1, Y, Z).
pyTony
pyMod
6,299 posts since Apr 2010
Reputation Points: 879
Solved Threads: 984
Skill Endorsements: 26
Question Answered as of 1 Year Ago by
pyTony