A366477 a(n) = smallest k such that A366475(k) >= n, or -1 if no such k exists.
2, 3, 29, 28025, 2467754261
Offset: 1
Programs
-
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 *)
-
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
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