A358344 a(1) = 0; a(n) = the smallest number such that the concatenation a(1)a(2)...a(n) is prime in the smallest allowed base; sequence terminates at index m if a(1)a(2)...a(m)k is composite in the smallest allowed base for all k.
0, 2, 1, 2, 2, 3, 1, 5, 9, 7, 21, 5, 31, 49, 39, 104, 2, 34, 44, 74, 22, 64, 16, 107, 549, 81, 207, 273, 87, 497, 27, 556, 42, 150, 32, 44, 144, 340, 28, 198, 677, 13, 61, 209, 377, 893, 329, 391, 49, 83, 425, 197, 1017, 205, 191, 163, 1131, 291, 281, 295, 389
Offset: 1
Examples
For a(6): The concatenation a(1)a(2)a(3)a(4)a(5) gives 2122. The smallest base in which 2122 can be read is max{2, 1, 2, 2} + 1 = 3, so test 21220_3 = 213 (nonprime), 21221_3 = 214 (nonprime), 21222_3 = 215 (nonprime). Now, 21223 is the next candidate; note that the new smallest allowed base is max{2, 1, 2, 2, 3} + 1 = 4, so test 21223_4 = 619 (prime). Thus, a(6) = 3.
Links
- Samuel Harkness, Table of n, a(n) for n = 1..1309
Programs
-
Mathematica
V = {0}; While[Length[V] <= 60, c = 0; d = 0; b = Max[V] + 1; CCC = 0; While[c == 0, X = V; X = Append[X, d]; CCC = 0; For[i = 1, i <= Length[X], i++, CCC += Part[X, i]*b^(Length[X] - i)]; If[PrimeQ[CCC], c = 1]; d++; If[d == b, b++]]; V = X]; Print[V]
-
Python
from sympy import isprime from itertools import count, islice def fd(d, b): return sum(di*b**i for i, di in enumerate(d[::-1])) def anext(alst): b = max(alst) return next(k for k in count(1) if isprime(fd(alst+[k], max(b, k)+1))) def agen(): alst = [0] while True: yield alst[-1]; alst.append(anext(alst)) print(list(islice(agen(), 61))) # Michael S. Branicky, Nov 11 2022
Extensions
Escape clause added by Jianing Song, Nov 28 2022
Comments