Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

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

by tye (Cardinal)
on May 19, 2001 at 12:00 UTC ( #81697=note: print w/ replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    sub sieve {
    my%p=(2,2);for my$n(3..pop){grep$n==($p{$_}+=$_*($p{$_}<$n)),keys%p
    or$p{$n}=$n}keys%p
    ...
    for( @ARGV ) {
        print "$_: ",join(" ",sort{$a<=>$b}sieve($_)),$/;
    }
    
  2. or download this
    1: 2
    2: 2
    3: 2 3
    ...
    701 709 719 727 733 739 743 751 757 761 769 773 787 797 809 811 821
    823 827 829 839 853 857 859 863 877 881 883 887 907 911 919 929 937
    941 947 953 967 971 977 983 991 997
    

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (6)
As of 2015-07-05 07:57 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 (61 votes), past polls