Yitzchak Gale schrieb: > Manlio Perillo wrote: >> However there is still a *big* problem: it is inefficient. >> >> Here is a Python version of the Chudnovsky algorithm [1] for computing Pi: >> http://paste.pocoo.org/show/102800/ >> On my system it takes 10 seconds. >> Here is an Haskell version: >> http://paste.pocoo.org/show/102801/ >> On my system it takes 30 seconds. > > Ah, OK. Thanks. Now we have a well-defined problem. :)
You would not need to handle huge interim results, if you compute the factorials incrementally. E.g. (n+1)!^3 = n!^3 * (n+1)^3 etc. 'scanl' is your friend. This should also be faster. _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe