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.




primes=: p: i. _1 p: 1000   NB. all prime numbers below 1000 
sums=: +/\ primes           NB. running sum of those primes 
mask=: 1 p: sums            NB. array of 0s, 1s where sums are primes 
 
NB. indices of prime sums (incremented for 1-based indexing)
NB. "copy" only the final primes in the prime sums
NB. "copy" only the sums which are prime 
results=: (>: I. mask) ,. (mask # primes) ,. (mask # sums)
 
NB. pretty-printed "boxed" output 
output=: 2 1 $ ' n prime sum ' ; < results