Skip to content

Latest commit

 

History

History
26 lines (17 loc) · 405 Bytes

Summation_of_primes.md

File metadata and controls

26 lines (17 loc) · 405 Bytes

Slow, but only using compiler built-ins (about 5 seconds)

say sum (^2e6).grep: {.&is-prime};

Output:

142913828922

Much faster using external libraries (well under half a second)

use Math::Primesieve;
my $sieve = Math::Primesieve.new;
say sum $sieve.primes(2e6.Int);

Same output