login
a(n) = (A364054(n+1) - A364054(n)) / prime(n) (where prime(n) denotes the n-th prime number).
2

%I #17 Mar 04 2024 19:48:02

%S 1,1,1,-1,1,-1,1,1,1,-1,1,-1,1,-1,1,-1,1,-1,1,-1,1,1,-1,1,-1,1,1,1,-3,

%T 2,-2,1,-1,1,-1,2,-1,1,-1,1,-1,1,-1,1,-1,1,-1,1,-1,1,-1,1,-1,1,-1,1,

%U -1,1,-1,1,-1,1,-1,1,-1,1,-1,1,-1,1,-1,1,-1,1,-1,1

%N a(n) = (A364054(n+1) - A364054(n)) / prime(n) (where prime(n) denotes the n-th prime number).

%C a(n) is the number of steps of size prime(n) in going from A364054(n) to A364054(n+1).

%H N. J. A. Sloane, <a href="/A366911/b366911.txt">Table of n, a(n) for n = 1..9999</a>

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

%e a(7) = (A364054(8) - A364054(7)) / prime(7) = (19 - 2) / 17 = 1.

%t nn = 2^16; c[_] := False; m[_] := 0; j = 1; 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]++];

%t Set[{a[n - 1], c[k], j}, {(k - j)/p, True, k}], {n, 2, nn + 1}], n];

%t Array[a, 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 A366911_gen(): # generator of terms

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

%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 i

%o break

%o b += p

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

%Y Cf. A160357, A364054, A366912 (partial sums).

%K sign

%O 1,29

%A _Rémy Sigrist_, Oct 27 2023