I've written a prlog recursive factorial clause which is:
factorial(X,Y):- (X>1) -> factorial(X-1,X*Y) ; write(Y). The problem is, for any valid call[for example, factorial(5,1). ], it is giving an expression rather than a value[(5-1-1-1)* ((5-1-1)* ((5-1)* (5*1)))]. How can I get a value rather than an expression.
A is 1+2, .....factorial(X-1, X*Y). They are just terms to Prolog unless you explicitly evaluate them withis/2, one of the numeric comparative operators (such as>/2) or with CLP(FD).