I'm trying to find how many numbers between 1 and 1000, which are not either prime or the sum of successive primes.
I've managed to create the list of all the primes between 1 and 1000:
primes = With[{list = Range[1000]}, Pick[list, PrimeQ[list]]]
And the sum:
sum[k_] := Sum[primes[[n]], {n, 1, k}]
which gives the summation of the primes from Prime[1]
to Prime[k]
.
How can I adapt this summation to be the sum of successive primes?
i.e. Prime[1] + Prime[2] , Prime[2] + Prime[3]
etc.?
And how can I use that to create a list of numbers which aren't prime or the sum of successive primes?
Partition
. $\endgroup$(#1 + #2) & @@@ Partition[primes, 2, 1]
$\endgroup$BlockMap[Total, primes, 2, 1]
$\endgroup$