diff options
| author | Joe Tym <joe.tym@gmail.com> | 2019-06-17 18:55:42 +0200 |
|---|---|---|
| committer | Joe Tym <joe.tym@gmail.com> | 2019-06-17 18:55:42 +0200 |
| commit | b5ecdf3ad5f40c99f2954b5add22b49c842c26b3 (patch) | |
| tree | 781b3577ee40ace87dc8596b0ca9c4f43fb87ea7 /challenge-012 | |
| parent | f3df34c6d0250c14f85c861bfca9a61b19a243d8 (diff) | |
| download | perlweeklychallenge-club-b5ecdf3ad5f40c99f2954b5add22b49c842c26b3.tar.gz perlweeklychallenge-club-b5ecdf3ad5f40c99f2954b5add22b49c842c26b3.tar.bz2 perlweeklychallenge-club-b5ecdf3ad5f40c99f2954b5add22b49c842c26b3.zip | |
use Math::Prime::FastSieve instead
Diffstat (limited to 'challenge-012')
| -rw-r--r-- | challenge-012/joe-tym/perl5/ch-1.pl | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/challenge-012/joe-tym/perl5/ch-1.pl b/challenge-012/joe-tym/perl5/ch-1.pl index 816bdfaa6b..98fcd2b392 100644 --- a/challenge-012/joe-tym/perl5/ch-1.pl +++ b/challenge-012/joe-tym/perl5/ch-1.pl @@ -4,6 +4,7 @@ use strict; use warnings; use PDL; use Data::Dumper; +use Math::Prime::FastSieve qw(primes); =head1 synopsis http://blogs.perl.org/users/laurent_r/2019/06/perl-weekly-challenge-12-euclids-numbers-and-directories.html @@ -15,17 +16,23 @@ use Data::Dumper; Pure Perl implementation(above) -> 0m26.662s PDL implementation(below) -> 0m0.284s NUMPY(1.8.2) implementation: -> 0m0.129s - + Math::Prime::FastSieve -> 0m0.122s + Perl script that does nothing, just use PDL; -> 0m0.132s - Python script that does nothing, just import numpy; -> 0m0.066s - + Python script that does nothing, just import numpy; -> 0m0.066s =cut main(); sub main { - my $primes = primesfrom2to(10000000); + my $n = 10000000; + my $primes_ref = primes($n); + my $primes = pdl($primes_ref); + #print Dumper($primes); + #exit; + #$primes = primesfrom2to($n); + #exit; my $last_prime_index = $primes->dim(0) - 1; for my $i (0..$last_prime_index) { |
