Complete the code to define the base case for the factorial function.
if (n == [1]) return 1;
The base case for factorial is when n equals 1, returning 1 stops the recursion.
Complete the code to write the recursive call for factorial.
return n * factorial([1]);
The recursive call reduces n by 1 each time to approach the base case.
Fix the error in the base case condition to prevent infinite recursion.
if (n [1] 1) return 1;
The base case must check if n equals 1 to stop recursion correctly.
Fill both blanks to complete the recursive factorial function.
public int Factorial(int n) {
if (n [1] 1) return 1;
return n [2] Factorial(n - 1);
}The base case uses '==' to check if n is 1, and the recursive case multiplies n by factorial of n-1.
Fill all three blanks to complete the recursive Fibonacci function.
public int Fibonacci(int n) {
if (n [1] 0) return 0;
if (n [2] 1) return 1;
return Fibonacci(n [3] 1) + Fibonacci(n - 2);
}The base cases check if n equals 0 or 1. The recursive call uses n - 1 and n - 2 to sum previous Fibonacci numbers.
