Visual Prolog Program to find the factorial of a number.
To find the factorial of a number in Visual Prolog, the number is decreased and the predicate “factorial” is continuously until a Zero is encountered when it returns a value 1. Then the predicate multiplies the returned value and the decremented number continuously. Thus, the factorial of a number is found. The visual prologue code to find the factorial of a number is given below:
PREDICATES
factorial(Integer,Integer)
Clauses
factorial(0,1).
factorial(X,Y):-
X<>0,S=X-1,factorial(S,Y1),Y=X*Y1.
Goal
factorial(5,X).
This information is really nice. This type of post is attracting people to read. Thank you for sharing. . .
ReplyDeletelocal house shifting services gurgaon.