Check if sum of first n primes is prime: Difference between revisions
Content added Content deleted
m (→{{header|Julia}}: style) |
m (→{{header|Julia}}: syntax) |
||
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>julia> filter(p -> isprime(p |
<lang julia>julia> filter(p -> isprime(last(p)), accumulate(+, primes(prime(158))) |> enumerate |> collect) |
||
20-element Vector{Tuple{Int64, Int64}}: |
20-element Vector{Tuple{Int64, Int64}}: |
||
(1, 2) |
(1, 2) |