Check if sum of first n primes is prime: Difference between revisions
Content added Content deleted
m (→{{header|Julia}}: typo) |
|||
Line 14: | Line 14: | ||
So, with a bit of experimentation, we find that to duplicate the Ring result we need to sum up to the first 158 primes, which then |
So, with a bit of experimentation, we find that to duplicate the Ring result we need to sum up to the first 158 primes, which then |
||
gives us 20 prime results when we filter for a prime number as the sum: |
gives us 20 prime results when we filter for a prime number as the sum: |
||
<lang julia> |
<lang julia>julia> filter(p -> isprime(p[2]), collect(enumerate(accumulate(+, primes(prime(158)))))) |
||
20-element Vector{Tuple{Int64, Int64}}: |
20-element Vector{Tuple{Int64, Int64}}: |
||
(1, 2) |
(1, 2) |