Suppose we have a sequence of prime sums, where each term Pn is the sum of the first n primes.

P = (2), (2 + 3), (2 + 3 + 5), (2 + 3 + 5 + 7), (2 + 3 + 5 + 7 + 11), ...

P = 2, 5, 10, 17, 28, etc.



Further; suppose we have a sequence of composite sums, where each term Cm is the sum of the first m composites.

C = (4), (4 + 6), (4 + 6 + 8), (4 + 6 + 8 + 9), (4 + 6 + 8 + 9 + 10), ...

C = 4, 10, 18, 27, 37, etc.



Notice that the third term of P; P3 (10) is equal to the second term of C; C2 (10);



Task
 Find and display the indices (n, m) and value of at least the first 6 terms of the sequence of numbers that are both the sum of the first n primes and the first m composites.


See also
 OEIS:A007504 - Sum of the first n primes
 OEIS:A053767 - Sum of first n composite numbers
 OEIS:A294174 - Numbers that can be expressed both as the sum of first primes and as the sum of first composites


with javascript_semantics 
atom t0 = time()
atom ps = 2,  -- current prime sum
     cs = 4   -- current composite sum
integer psn = 1, npi = 1,  -- (see below)
        csn = 1, nci = 3, nc = 4, ncp = 5,
        found = 0
constant limit = iff(platform()=JS?10:11)
while found<limit do
    integer c = compare(ps,cs) -- {-1,0,+1}
    if c=0 then
        printf(1,"%,21d - %,10d%s prime sum, %,10d%s composite sum   (%s)\n",
                 {ps, psn, ord(psn), csn, ord(csn), elapsed(time()-t0)})
        found += 1
    end if
    if c<=0 then
        psn += 1    -- prime sum number
        npi += 1    -- next prime index
        ps += get_prime(npi)
    end if
    if c>=0 then
        csn += 1    -- composite sum number
        nc += 1     -- next composite?
        if nc=ncp then  -- "", erm no
            nci += 1    -- next prime index
            ncp = get_prime(nci)
            nc += 1 -- next composite (even!)
        end if
        cs += nc
    end if
end while
