public static double factorial ( int x ) { double result = 1.0 ; for ( int i = x ; i > 1 ; i -- ) { result *= i ; } return result ; }
Uses floating point so that it can represent the really big numbers that come up .