login
A366477
a(n) = smallest k such that A366475(k) >= n, or -1 if no such k exists.
3
2, 3, 29, 28025, 2467754261
OFFSET
1,1
MATHEMATICA
nn = 2^16; c[_] := False; m[_] := 0; j = 1; c[0] = c[1] = True; q[_] := 0; s = -1;
Monitor[Do[p = Prime[n - 1]; r = Mod[j, p];
While[Set[k, p m[p] + r ]; c[k], m[p]++];
(If[q[#] == 0, Set[q[#], n]]; If[# > s, s = #]) &[ m[p] ];
Set[{c[k], j}, {True, k}], {n, 2, nn}], n];
Array[q, s] (* Michael De Vlieger, Oct 27 2023 *)
PROG
(Python)
from itertools import count
from sympy import nextprime
def A366477(n):
a, aset, p = 1, {0, 1}, 1
for i in count(2):
p = nextprime(p)
b = a%p
for j in count(0):
if b not in aset:
aset.add(b)
a = b
break
b += p
if j>=n:
return i # Chai Wah Wu, Oct 27 2023
CROSSREFS
Sequence in context: A377471 A350868 A270550 * A076977 A328833 A109886
KEYWORD
nonn,more
AUTHOR
N. J. A. Sloane, Oct 26 2023
EXTENSIONS
a(4) = 28025 from Michael De Vlieger, Oct 26 2023, who also reports that 5 does not appear in the first 2^24 terms of A366475.
a(5) from Chai Wah Wu, Oct 28 2023
STATUS
approved