Question: Write the Prolog rules for factorial ( X , Y ) which sets Y to the factorial of X . Recall the factorial of 0

Write the Prolog rules for factorial(X,Y) which sets Y to the factorial of X.
Recall the factorial of 0 is 1 and the factorial of X is Z if X is not equal to 0 and Z is equal to X*W where W is the factorial of X-1.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!