> For the complete documentation index, see [llms.txt](https://trizen.gitbook.io/perl6-rosettacode/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://trizen.gitbook.io/perl6-rosettacode/programming_tasks/s/summation_of_primes.md).

# Summation of primes

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

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

#### Output:

```
142913828922
```

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

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

Same output
