Factorial in prolog

Submitted by:Andery Smith

Date added:02 July, 2011

Category:Prolog

The predicate returns true if Y is the factorial of X

Tags: factorial in prolog

Code Snippet:

fact(0, 1).

fact(X, Y):-
X > 0 ,X1 is X-1, fact(X1, Z), Y is X*Z.
 
 

Comments