login
Partial sums of A366911: a(1) = 0, and for n > 0, a(n+1) = a(n) + A366911(n).
3

%I #10 Oct 27 2023 22:19:20

%S 0,1,2,3,2,3,2,3,4,5,4,5,4,5,4,5,4,5,4,5,4,5,6,5,6,5,6,7,8,5,7,5,6,5,

%T 6,5,7,6,7,6,7,6,7,6,7,6,7,6,7,6,7,6,7,6,7,6,7,6,7,6,7,6,7,6,7,6,7,6,

%U 7,6,7,6,7,6,7,6,7,6,7,8,6,7,8,9,8,9,8

%N Partial sums of A366911: a(1) = 0, and for n > 0, a(n+1) = a(n) + A366911(n).

%C By analogy with A064289, a(n) corresponds to the height of A364054(n) = number of addition steps - number of subtraction steps to produce it.

%H Rémy Sigrist, <a href="/A366912/a366912.png">Colored scatterplot of the first 100000 terms of A364054</a> (where the color is function of a(n))

%H Rémy Sigrist, <a href="/A366912/a366912.gp.txt">PARI program</a>

%F a(n) = Sum_{k = 1..n-1} A366911(k).

%e a(5) = A366911(1) + A366911(2) + A366911(3) + A366911(4) = 1 + 1 + 1 - 1 = 2.

%t nn = 2^16; c[_] := False; m[_] := 0; j = 1; s = b[1] = 0;

%t c[0] = c[1] = True;

%t Monitor[Do[p = Prime[n - 1]; r = Mod[j, p];

%t While[Set[k, p m[p] + r ]; c[k], m[p]++]; s += (k - j)/p;

%t Set[{a[n - 1], b[n - 1], c[k], j}, {(k - j)/p, s, True, k}],

%t {n, 2, nn + 1}], n];

%t Array[b, nn] (* _Michael De Vlieger_, Oct 27 2023 *)

%o (PARI) See Links section.

%o (Python)

%o from itertools import count, islice

%o from sympy import nextprime

%o def A366912_gen(): # generator of terms

%o a, aset, p, c = 1, {0,1}, 2, 0

%o while True:

%o k, b = divmod(a,p)

%o for i in count(-k):

%o if b not in aset:

%o aset.add(b)

%o a, p = b, nextprime(p)

%o yield c

%o c += i

%o break

%o A366912_list = list(islice(A366912_gen(),30)) # _Chai Wah Wu_, Oct 27 2023

%Y Cf. A064289, A364054, A366911, A366913.

%K nonn

%O 1,3

%A _Rémy Sigrist_, Oct 27 2023