home *** CD-ROM | disk | FTP | other *** search
Prolog Source | 1990-03-26 | 339 b | 18 lines |
- /*
- Copyright (c) 1986, 90 by Prolog Development Center
- */
-
- /* Recursive program to compute factorials.
- Ordinary recursion, not tail recursion. */
-
- predicates
- factorial(integer, real)
-
- clauses
- factorial(1, 1) :- !.
-
- factorial(X, FactX) :-
- Y = X-1,
- factorial(Y, FactY),
- FactX = X*FactY.