For this problem, you are goign to write a recursive function to calculate the factorial of a number. Remember, factorial is the product of an integer and all the integers below it. This function...


For this problem, you are goign to write a recursive function to calculate the factorial of a number. Remember, factorial is the product of an integer and all the integers below it. This function should be similar to the summing example we looked at earlier.



Note: Make sure you enter small numbers to test. Factorial will overflow the int value very quickly!




import java.util.Scanner;


public class Factorial
{
public static void main(String[] args)
{
Scanner input = new Scanner(System.in);
System.out.println("Please enter a number: ");
int number = input.nextInt();


System.out.println(calcFactorial(number));
}


public static int calcFactorial(int x)
{
// Write a base case


// Call the simplified solution
}
}



Jun 03, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions ยป

Submit New Assignment

Copy and Paste Your Assignment Here