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