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 (Sage)
on May 19, 2001 at 12:00 UTC ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://81697]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (7)
As of 2024-03-29 09:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found