Question: Write a Prolog predicate factorial ( N , Result ) that calculates the factorial of a given number N and binds the result to Result
Write a Prolog predicate factorial Result that calculates the factorial of a given number and binds the result
to Result
Base case: the factorial of is
Recursive case: If is greater than it calculates the factorial of using recursion by invoking
factorialN Result and then multiplies it by to get the factorial of
Use the following Query as a test case:
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
