I have to write a predicate, which count a factorial of given number. The goal is to use only predicates, not built-in prolog arithmetic.
factorial(N,X) - where X = !N
example how it must be done on different predicate (sum of two numbers) :
isnumber(zero).
isnumber(s(X)) :- isnumber(X).
add(zero,X,X) :- isnumber(X).
add(s(X),Y,s(Z)) :- add(X,Y,Z).
I tried multiple times, but I can't find a solution. Thank you for your answers.