in reply to Re: Re: Factorial algorithm execution time
in thread Factorial algorithm execution time

You're right. But why so much work? A trivial modification to my code will do that.
sub fact7b { my @factor = map Math::BigInt->new($_), (2 .. shift); while(@factor > 1) { my @pair = splice @factor, 0, @factor / 2; $_ = $_ * pop @pair for @factor[0..$#pair]; } return shift @factor; }
Update: doh, fixed overly clever, broken code. (s{1 + $#factor / 2}{@factor / 2})

Makeshifts last the longest.

Replies are listed 'Best First'.
Re: Re^3: Factorial algorithm execution time
by Anonymous Monk on Oct 19, 2002 at 11:20 UTC
    Did you test that code?