Sum of primes in odd positions is prime
Sum of primes in odd positions is prime is a draft programming task. It is not yet considered ready to be promoted as a complete task, for reasons that should be found in its talk page.
- Task
Let p(n) be a sequence of prime numbers.
Consider the p(1),p(3),p(5), ... ,p(i), for each p(i) < 1,000 and i is odd.
Let sum be summarize of these primes.
If sum is prime then print p(i) and sum
Ring
<lang ring> load "stdlib.ring" see "working..." + nl see "p" + " sum" + nl
nr = 0 sum = 0 limit = 1000
for n = 2 to limit
if isprime(n) nr++ if nr%2 = 1 sum += n if isprime(sum) see "" + n + " " + sum + nl ok ok ok
next
see "done..." + nl </lang>
- Output:
working... p sum 2 2 5 7 31 89 103 659 149 1181 331 5021 467 9923 499 10909 523 11941 653 17959 823 26879 done...