Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re^3: Factorial algorithm execution time

by Aristotle (Chancellor)
on Oct 18, 2002 at 17:41 UTC ( [id://206377]=note: print w/replies, xml ) Need Help??


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?

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://206377]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (8)
As of 2024-03-28 09:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found