//******************************************************************* // DemoFactorial.java //******************************************************************* public class DemoFactorial { public static int factorial(int N) { if (N == 0) { // Base case return(1); } else { int sol; int solX; sol = factorial(N-1); // Solve smaller problem solX = sol * N; // Solve Problem X using sol return(solX); } } public static void main (String[] args) { System.out.println ("Factorial of 6 is " + factorial(6)); System.out.println ("Factorial of 10 is " + factorial(10)); System.out.println ("Factorial of 11 is " + factorial(11)); System.out.println ("Factorial of 12 is " + factorial(12)); System.out.println ("Factorial of 13 is " + factorial(13)); } // method main }