OFFSET
2,2
COMMENTS
a(29) = 3. When, if ever, does 4 appear?
Answer: a(28025) = 4. - Michael De Vlieger, Oct 26 2023
LINKS
Michael De Vlieger, Table of n, a(n) for n = 2..65536
Michael De Vlieger, 2048 X 2048 raster showing a(n), n = 1..4194304 in rows of 2048 terms, left to right, then continued below for 2048 rows total. Color indicates terms as follows: black = 0, blue = 1, green = 2, gold = 3, red = 4.
EXAMPLE
MATHEMATICA
nn = 2^20;
c[_] := False; m[_] := 0; a[1] = 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], b[n], c[k], j}, {k, m[p], True, k}], {n, 2, nn}], n];
Array[b, nn-1, 2] (* Michael De Vlieger, Oct 26 2023 *)
PROG
(Python)
from itertools import count, islice
from sympy import nextprime
def A366475_gen(): # generator of terms
a, aset, p = 1, {0, 1}, 1
while True:
p = nextprime(p)
b = a%p
for i in count(0):
if b not in aset:
aset.add(b)
a = b
break
b += p
yield i
CROSSREFS
KEYWORD
nonn
AUTHOR
N. J. A. Sloane, Oct 26 2023
STATUS
approved