OFFSET
1,3
COMMENTS
LINKS
Rémy Sigrist, Colored scatterplot of the first 100000 terms of A364054 (where the color is function of a(n))
Rémy Sigrist, PARI program
FORMULA
a(n) = Sum_{k = 1..n-1} A366911(k).
MATHEMATICA
nn = 2^16; c[_] := False; m[_] := 0; j = 1; s = b[1] = 0;
c[0] = c[1] = True;
Monitor[Do[p = Prime[n - 1]; r = Mod[j, p];
While[Set[k, p m[p] + r ]; c[k], m[p]++]; s += (k - j)/p;
Set[{a[n - 1], b[n - 1], c[k], j}, {(k - j)/p, s, True, k}],
{n, 2, nn + 1}], n];
Array[b, nn] (* Michael De Vlieger, Oct 27 2023 *)
PROG
(PARI) See Links section.
(Python)
from itertools import count, islice
from sympy import nextprime
def A366912_gen(): # generator of terms
a, aset, p, c = 1, {0, 1}, 2, 0
while True:
k, b = divmod(a, p)
for i in count(-k):
if b not in aset:
aset.add(b)
a, p = b, nextprime(p)
yield c
c += i
break
CROSSREFS
KEYWORD
nonn
AUTHOR
Rémy Sigrist, Oct 27 2023
STATUS
approved