[Nickle] Fwd: nickle slow for large factorials
Keith Packard
keithp at keithp.com
Mon Jul 5 21:35:34 PDT 2010
On Sun, 4 Jul 2010 11:32:46 +0200, Michel Alexandre Salim <michael.silvanus at gmail.com> wrote:
> It looks like Nickle's handling of bignums is inefficient -- has there
> been thoughts about using GMP for large numbers? The tail recursion
> itself is fine, even for mutually recursive functions:
I've implemented a more efficient factorial function as described by
Peter Luschny as described here:
http://www.luschny.de/math/factorial/FastFactorialFunctions.htm
This still isn't amazingly fast for large factorials (666666 takes a bit
more than a minute), but is a whole lot faster than the naïve algorithm
originally included in nickle, and should be faster than the GMP
factorial algorithm for large values, although I haven't compared it
myself.
This code is on the master branch in the nickle repository; please feel
free to give it a try.
--
keith.packard at intel.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: </pipermail/nickle/attachments/20100706/05ac8440/attachment.pgp>
More information about the Nickle
mailing list