login
A344324
Let b be the lexicographically earliest weakly increasing sequence of squares such that Sum_{k = 1..m} prime(k) <= Sum_{k = 1..m} b(k) for any m > 0 (where prime(k) denotes the k-th prime number); a(n) = Sum_{k = 1..n} (b(k) - prime(k)).
1
2, 3, 2, 4, 2, 5, 4, 1, 3, 10, 15, 14, 9, 2, 4, 0, 5, 8, 5, 15, 23, 25, 23, 15, 18, 17, 14, 7, 19, 27, 21, 11, 18, 23, 18, 11, 23, 29, 31, 27, 17, 5, 10, 13, 12, 9, 23, 25, 23, 19, 11, 28, 43, 48, 47, 40, 27, 12, 24, 32, 38, 34, 16, 29, 40, 47, 40, 27, 4, 16
OFFSET
1,1
COMMENTS
This sequence is a variant of A338699; here we use squares, there powers of 2.
EXAMPLE
The first terms, alongside the prime numbers (p(n)) and their partial sums (pp(n)), b(n) and their partial sums (bb(n)), are:
n a(n) p(n) pp(n) b(n) bb(n)
-- ---- ---- ----- ---- -----
1 2 2 2 4 4
2 3 3 5 4 8
3 2 5 10 4 12
4 4 7 17 9 21
5 2 11 28 9 30
6 5 13 41 16 46
7 4 17 58 16 62
8 1 19 77 16 78
9 3 23 100 25 103
10 10 29 129 36 139
11 15 31 160 36 175
12 14 37 197 36 211
13 9 41 238 36 247
14 2 43 281 36 283
15 4 47 328 49 332
PROG
(PARI) pp=0; bb=0; b=0; forprime (p=2, 349, pp+=p; while (bb+b^2<pp, b++); bb+=b^2; print1 (bb-pp", "))
CROSSREFS
KEYWORD
nonn
AUTHOR
Rémy Sigrist, May 15 2021
STATUS
approved