OFFSET
2,4
LINKS
Chai Wah Wu, Table of n, a(n) for n = 2..10000
Michael De Vlieger, Log log scatterplot of a(n), n = 1..2^20.
Michael De Vlieger, Log log scatterplot of a(n), n = 2..2^20, showing a(n) = 0 instead as a(n) = 1/10, with a color function showing b(n) = 0 in black, b(n) = 1 in blue, b(n) = 2 in green, b(n) = 3 in chartreuse, and b(n) = 4 in red, where b() = A366475(). (The plot accentuates larger values of b(n) through larger size, so adjacent smaller values may be eclipsed.)
Chai Wah Wu, Graph of first 10^8 terms
FORMULA
MATHEMATICA
nn = 2^20; c[_] := False; m[_] := 0; j = 1; 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]++];
Set[{a[n - 1], c[k], j}, {r, True, k}], {n, 2, nn + 1}], n];
Array[a, nn] (* Michael De Vlieger, Oct 27 2023 *)
PROG
(Python)
from itertools import count, islice
from sympy import nextprime
def A366470_gen(): # generator of terms
a, aset, p = 1, {0, 1}, 2
while True:
yield a
for b in count(a, p):
if b not in aset:
aset.add(b)
a = b%(p:=nextprime(p))
break
CROSSREFS
KEYWORD
nonn
AUTHOR
N. J. A. Sloane, Oct 21 2023
STATUS
approved