Let's consider that n=s(s(...s(0)...)) (simply n= s^n(0)). How could write a program calculating the division of two integers? I mean s^(n//m) (thats the definition of the division) . Any ideas? For example, if we had the question:
?-divide(s(s(s(s(0)))),s(0),D).
i have written the following code:
nat(0).
nat(s(X)) :- nat(X).
divide(0,_,D) :- D is 0.
divide(s(X),s(Y),D) :- divide(X,Y,D).