# Summations of Lists

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}, Pick[list, PrimeQ[list]]]


And the sum:

sum[k_] := Sum[primes[[n]], {n, 1, k}]


which gives the summation of the primes from Prime to Prime[k].

How can I adapt this summation to be the sum of successive primes?

i.e. Prime + Prime , Prime + Prime etc.?

And how can I use that to create a list of numbers which aren't prime or the sum of successive primes?

• What do you mean by sum of successive primes? Apr 13, 2018 at 21:37
• Once the list of prime numbers is created, I want to create another list where I add the first and second primes, then the second and third primes, third and forth, and so on. i.e 2+3=5, 3+5=8, 5+7=12 etc. Apr 13, 2018 at 21:41
• Have a look at Partition. Apr 13, 2018 at 21:52
• Try this: (#1 + #2) & @@@ Partition[primes, 2, 1] Apr 13, 2018 at 21:55
• You might like BlockMap[Total, primes, 2, 1]
– chuy
Apr 13, 2018 at 21:57

Here are the sums of successive primes, which are all the way upto $1088$

primeSums = Table[Prime[i + 1] + Prime[i], {i, 100}];


Here are primes upto 1069:

primes = Table[Prime[i], {i, 180}];


We consider the Complement of first 1000 numbers from these lists:

Complement[Range, primes, primeSums]


which gives what you seek. For example, for the first 100 numbers, we get

Complement[Range, primes, primeSums]


{1, 4, 6, 9, 10, 14, 15, 16, 20, 21, 22, 25, 26, 27, 28, 32, 33, 34, 35, 38, 39, 40, 44, 45, 46, 48, 49, 50, 51, 54, 55, 56, 57, 58, 62, 63, 64, 65, 66, 69, 70, 72, 74, 75, 76, 77, 80, 81, 82, 85, 86, 87, 88, 91, 92, 93, 94, 95, 96, 98, 99}

With[{primes = Prime @ Range @ PrimePi @ 1000}, Length @
Complement[Range @ 1000, primes, Total[Partition[primes, 2, 1], {2}]]]


739