%I #28 Oct 28 2023 00:25:07
%S 1,2,2,0,1,0,1,2,2,1,2,0,1,0,1,0,1,0,1,0,1,2,0,1,0,1,2,3,0,2,0,1,0,1,
%T 0,2,1,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,
%U 0,1,0,1,0,1,0,1,0,1,2,0,1,2,2,1,2,1,2,0,1,2,0,2,0
%N a(n) = (A364054(n) - A366470(n))/prime(n-1).
%C a(29) = 3. When, if ever, does 4 appear?
%C Answer: a(28025) = 4. - _Michael De Vlieger_, Oct 26 2023
%H Michael De Vlieger, <a href="/A366475/b366475.txt">Table of n, a(n) for n = 2..65536</a>
%H Michael De Vlieger, <a href="/A366475/a366475.png">2048 X 2048 raster showing a(n)</a>, 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.
%e n p(n-1) x y a(n) [x = A364054(n), y = A366470(n)]
%e 1 (1) 1 - - [a(n) = (x-y)/p(n-1)]
%e 2 2 3 1 1
%e 3 3 6 0 2
%e 4 5 11 1 2
%e 5 7 4 4 0
%e 6 11 15 4 1
%e 7 13 2 2 0
%e ...
%t nn = 2^20;
%t c[_] := False; m[_] := 0; a[1] = 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], b[n], c[k], j}, {k, m[p], True, k}], {n, 2, nn}], n];
%t Array[b, nn-1, 2] (* _Michael De Vlieger_, Oct 26 2023 *)
%o (Python)
%o from itertools import count, islice
%o from sympy import nextprime
%o def A366475_gen(): # generator of terms
%o a, aset, p = 1, {0,1}, 1
%o while True:
%o p = nextprime(p)
%o b = a%p
%o for i in count(0):
%o if b not in aset:
%o aset.add(b)
%o a = b
%o break
%o b += p
%o yield i
%o A366475_list = list(islice(A366475_gen(),30)) # _Chai Wah Wu_, Oct 27 2023
%Y Cf. A364054, A366470, A366477 (records).
%K nonn
%O 2,2
%A _N. J. A. Sloane_, Oct 26 2023