Task

Considering in order of length, n, all sequences of consecutive
primes, p, from 2 onwards, where p < 1000 and n>0, select those
sequences whose sum is prime, and for these display the length of the
sequence, the last item in the sequence, and the sum.




F is_prime(a)
   I a == 2
      R 1B
   I a < 2 | a % 2 == 0
      R 0B
   L(i) (3 .. Int(sqrt(a))).step(2)
      I a % i == 0
         R 0B
   R 1B
 
print(‘index  prime  prime sum’)
V s = 0
V idx = 0
L(n) 2..999
   I is_prime(n)
      idx++
      s += n
      I is_prime(s)
         print(f:‘{idx:3}   {n:5}   {s:7}’)