
24 Apr
2007
24 Apr
'07
1:33 p.m.
Dan Weston wrote:
A thing of beauty is a joy forever. Simple, fast, elegant.
factorial :: Integer -> Integer factorial = product . zipWith (^) . factorisedFactorial
Well... The zipWith (^) should be map (uncurry (^)). And the performance of this approach is strongly dependent on the efficiency of your prime sieve, so you're moving the complexity around, not eliminating it. The binary splitting method doesn't need a source of primes, and performs half decently on numbers such as fact 1e6 (5.5 million digits computed in about 5 seconds).