/** * RECURSIVE FACTORIAL COMPUTATON * calculates n! i.e. n*(n-i)*(n-2) ... 3*2*1 * for 0 <= n <= 20 * Uses recursion, counting down. * Had we used ints we would be limited to 12! */ static long factorial( long n ) { assert 0 <= n && n <= 20 : "factorial only handles numbers 0 to 20"; if ( n == 0 ) { return 1; } else return n * factorial( n-1 ); }