public class DivideAndConquer { public static void main(String[] args) { int r; r = factorial(4); } public static int factorial(int n) { int helpSol; // Solution to the smaller problem int mySol; // Solution to my problem if ( n == 0 ) return 1; else { helpSol = factorial(n-1); // Tell someone to solve this // (We receive the solution in helpSol) mySol = n*helpSol; // Solve my problem using the // solution of the smaller problem return(mySol); } } }