Why is factorial calculation much faster in Haskell than in Java
One of the programming problems I have come across involves calculation of factorials of large numbers (of numbers up to 10^5). I have seen a simple Haskell code which goes like this factorial :: (Eq x, Num x) => x -> x factorial 0 = 1 factorial a = a * factorial (a - 1) which implicitly handles the huge numbers and somehow runs faster even without any caching that is involved in the code. When I tried to solve the problem using Java, I had to use BigInteger to hold the huge numbers and also use iterative version of factorial public static BigInteger factorialIterative(int n) { if(n == 0 || n