Prime numbers p for which the sum of primes less than or equal to p is prime: Difference between revisions
Content added Content deleted
Line 166: | Line 166: | ||
Found 21 such primes |
Found 21 such primes |
||
</pre> |
|||
=={{header|Julia}}== |
|||
<lang julia>using Primes |
|||
primesumto(N) = begin s = 0; Dict(i => s for i in 1:N if isprime(i) && isprime(s += i)) end |
|||
const primesumdict = primesumto(1000) |
|||
println("Prime Prime Sum to Prime\n---------------------------") |
|||
for k in primesumdict |> keys |> collect |> sort |
|||
println(rpad(k, 7), primesumdict[k]) |
|||
end |
|||
println("\nTotal such primes < 100: ", length(primesumdict)) |
|||
</lang>{{out}} |
|||
<pre> |
|||
Prime Prime Sum to Prime |
|||
--------------------------- |
|||
2 2 |
|||
3 5 |
|||
7 17 |
|||
13 41 |
|||
37 197 |
|||
43 281 |
|||
281 7699 |
|||
311 8893 |
|||
503 22039 |
|||
541 24133 |
|||
557 25237 |
|||
593 28697 |
|||
619 32353 |
|||
673 37561 |
|||
683 38921 |
|||
733 43201 |
|||
743 44683 |
|||
839 55837 |
|||
881 61027 |
|||
929 66463 |
|||
953 70241 |
|||
Total such primes < 100: 21 |
|||
</pre> |
</pre> |
||