[Home]
[Edit this page]
[Recent Changes]
[Special Pages]
[Help]
PrologFactorial
[Edit this page] [Page history] [What links here] [Discuss this topic] [Printer Friendly]
PrologFactorial
(Prolog) Calculating the factorial
PREDICATES
nondeterm factorial(integer, integer)
CLAUSES
factorial(0,1).
factorial(Number,Factorial) if
Number > 0
and LowerNumber = Number - 1
and factorial(LowerNumber, X)
and Factorial = Number * X.
GOAL
factorial(5,X).
'factorial' links
[Edit this page] [Page history] [What links here] [Discuss this topic] [Printer Friendly]
