factorial(0,1):- !.
factorial(X, Y):- 
	Y is X*Y,
	factorial(X-1, Y),
	write(Y).