public class Factorial { public static void main(String[] args) { System.out.println( "Factorial of 18 is " + factorial(18) ); } // Extensive use of variables public static long factorialOld( int x ) { long f = 1; for ( int i = 1 ; i <= x ; i++ ) { f *= i; } return f; } // Reduction of variable use via recursion public static long factorial( int x ) { System.out.println( "In factorial() method with x=" + x ); if ( x == 1 ) { return 1; } else { return x * factorial( x - 1 ); } } }