fact(0,1). fact(X,Y) :- X > 0, Xp is X-1, fact(Xp,Yp), Y is Yp*X.