Question: Question 19 Consider the following function: public static int factorial(int n) { if( n == 0) return 1; else return (n-1)* factorial(n); } a) Explain
Question 19
Consider the following function:
public static int factorial(int n) {
if( n == 0) return 1; else return (n-1)* factorial(n);
}
a) Explain why this program has infinite recursion.
b) How would you correct this function to correctly calculate factorials?
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
