A309655 The smallest possible nonnegative difference between the sum of the first n primes (A007504) and the sum of any number of the directly following and consecutive primes.
0, 2, 0, 3, 6, 15, 5, 16, 25, 3, 20, 39, 13, 36, 61, 17, 50, 6, 39, 76, 14, 53, 102, 28, 75, 132, 46, 101, 158, 46, 99, 174, 64, 145, 27, 114, 193, 51, 144, 239, 93, 194, 24, 135, 244, 74, 179, 294, 116, 253, 43, 162, 291, 61, 196, 337, 101, 250, 395, 139, 282, 427, 149, 324
Offset: 0
Examples
a(2) = 2 + 3 - 5 = 0; a(3) = 2 + 3 + 5 - 7 = 3; a(6) = 2 + 3 + 5 + 7 + 11 + 13 - (17 + 19) = 5. a(532)=0 because A007504(733) = 2*A007504(532).
Links
- David Radcliffe, Table of n, a(n) for n = 0..10000
Programs
-
Python
#Lists a(1)...a(100) from sympy import prime sumP=0 for i in range(1,101): sumP+=prime(i) j=i+1 diff=sumP while diff-prime(j) >=0: diff-=prime(j) j+=1 print(diff, end=', ')
-
Python
from itertools import islice from gmpy2 import next_prime def a309655_gen(): lower_prime = upper_prime = difference = 0 while True: while difference >= 0: upper_prime = next_prime(upper_prime) if difference < upper_prime: yield int(difference) difference -= upper_prime lower_prime = next_prime(lower_prime) difference += 2 * lower_prime print(list(islice(a309655_gen(), 64))) # David Radcliffe, Jun 10 2025
Comments