I am trying to write simple case in mod function of two peano's number in prolog , put some case it give me wrong answer I don't know what is the problem with my code
simple case is if C smaller than D return C
mod(C,D,F):- smaller(C,D) -> mod(C,D,C).
I don't have output
thank you.
Cis smaller thanD(smaller(C, D)succeeds), then you recursively check ifCisCmoduloD(you callmod(C,D,C), which will go into an infinite recursion. A big clue here is your result should beFbut you make no reference toFin your predicate clause. I'm sure you saw the singleton variable warning forF. What do you really want to happen ifsmaller(C, D)succeeds? (HINT: you wantFto be something.) - lurker