2.7k views
5 votes
CHALLENGE ACTIVITY 12.5.2: Recursive method: Writing the recursive case. Write code to complete printFactorial()'s recursive case. Sample output if input is 5: 5! = 5 * 4 * 3 * 2 * 1 = 120 1 import java.util.Scanner; 3 public class RecursivelyPrintFactori public static void printFactorial(int factCounter, int factValue) { 5 nt nextCounter; int nextValue; | if (factCounter == ) { / Base case System.out.println("1"); le 13 15 else if (factCounter = 1) { / Base case: Print System.out.println(factCounter + " else { // Recursive case System.out.print(factCounter + "* nextCounter factCounter 1; nextValue - nextCounter " factValue; 1* Your solution goes here 18 20 J UUL Write code to complete printFactorial()'s recursive case. Sample output if inpl 5! = 5 * 4 * 3 * 2 * 1 = 120 System.out.printin(tactlounter + = + tactvalue); else { / Recursive case System.out.print (factCounter + nextCounter = factCounter - 1; nextValue = nextCounter factValue; Your solution goes here public static void main (String [] args) { Scanner sehr = new Scanner(System.in); int userval; userval - scnr.nextInt(); System.out.print(userval - "!= "); printFactorial(userval, userval); Run

User Tutuca
by
8.5k points

1 Answer

4 votes

Answer:

printFactorial(nextCounter, nextValue);

Step-by-step explanation:

to write the printFactorial()'s recursive case, it would be printFactorial(nextCounter, nextValue);

User Abhishek Mohanty
by
7.8k points