Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

The sieve of Xuedong Luo (Algorithm3) for generating prime numbers

by marioroy (Prior)
on Jun 11, 2015 at 04:34 UTC ( [id://1129972]=perlmeditation: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    k = 3 - k;
    
  2. or download this
    /* Sieve of Eratosthenes.  Return a reference to an array containing a
    +ll
     * prime numbers less than or equal to search_to.  Uses an optimized s
    +ieve
    ...
              av_push( av, newSVuv( static_cast<unsigned long>( i ) ) );
        return newRV_noinc( (SV*) av );
    }
    
  3. or download this
    /* Sieve of Xuedong Luo (Algorithm3). Return a reference to an array
     * containing all prime numbers less than or equal to search_to.
    ...
    
        return newRV_noinc( (SV*) av );
    }
    
  4. or download this
    my $primes = primes( 1_000_000_000 );
    
    ...
    
    There are 50,847,534 prime numbers between 1 and 1 billion.
    
  5. or download this
    #
    # Count primes
    ...
    
    perl primeutil.pl  4_294_967_296 --print >/dev/null
    Compute time  : 13.470 sec
    
  6. or download this
    Count primes
    
    ...
       $ perl primeutil.pl 4294967296 --print >/dev/null
       Compute time  : 1.925 sec
    

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlmeditation [id://1129972]
Approved by Corion
Front-paged by Athanasius
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (5)
As of 2024-04-24 18:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found