One of the most common examples of recursion is an algorithm to calculate the factorial of an integer. The notation n! is used for the factorial of the integer n and is defined as follows
0! is equal to 1
1! is equal to 1
2! is equal to 2 × 1 = 2
3! is equal to 3 × 2 × 1 = 6
4! is equal to 4 × 3 × 2 × 1 = 24
...
n! is equal to n× (n– 1)× (n– 2) × …× 3 × 2 × 1
An alternative way to describe the calculation of n! is the recursive formula n× (n – 1)!, plus a base case of 0!, which is 1. Write a static method that implements this recursive formula for factorials. Place the method in a test program that allows the user to enter values for n until signaling an end to execution.
We need at least 10 more requests to produce the solution.
0 / 10 have requested this problem solution
The more requests, the faster the answer.