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.




1000.primes.map_reduce {|a,b| a + b }.map_kv {|k,v|
    [k+1, prime(k+1), v]
}.grep { .tail.is_prime }.prepend(
    ['count', 'prime', 'sum']
).each_2d {|n,p,s|
    printf("%5s %6s %8s\n", n, p, s)
}