Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: (tye)Re3: (Golf): Sieve of Eratosthenes

by tilly (Archbishop)
on Feb 26, 2011 at 01:23 UTC ( #890247=note: print w/ replies, xml ) Need Help??


in reply to (tye)Re3: (Golf): Sieve of Eratosthenes
in thread (Golf): Sieve of Eratosthenes

And almost a decade later I was randomly looking at this, and realized that it could be made shorter still.

sub sieve3 { grep{@_[map$a*$_,2..@_/($a=$_)]=0if$_[$_]>1}@_=0..pop }
Never give up on that last optimization!


Comment on Re: (tye)Re3: (Golf): Sieve of Eratosthenes
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (5)
As of 2015-07-29 01:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (260 votes), past polls