| ?- [user].
factorial(0,1).
factorial(N,F) :-
N>0,
N1 is N-1,
factorial(N1,F1),
F is N * F1.
**Here you hit <CTRL>-<D> on the empty line**
user compiled, 7 lines read - 822 bytes written, 24027 ms
yes
| ?- factorial(5,W).
W = 120 ?
Website maintained by Andy Long.
Comments appreciated.