This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.
%I A356557 #49 Jun 12 2023 12:33:09 %S A356557 2,23,233,2333,23333,233323,2333231,23332301,233323001,2333230019, %T A356557 23332030019,233320360019,2333203600159,23332036001959, %U A356557 233320360019569,2333203600195669,23332036001956469,233320360019564269,2333203600195642469,23332036001956424629,233320360019564246269 %N A356557 Start with a(1)=2; to get a(n+1) insert in a(n) at the rightmost possible position the smallest possible digit such that the new number is a prime. %C A356557 Extending a number by inserting a prepending "0" is obviously not allowed. Rightmostness of position has precedence over smallness of digit. If no prime extension exists, the sequence terminates. %C A356557 Sequence inspired by A332603. %C A356557 Sequence construction very similar to A357436 (the difference arises from the order of the conditions). %C A356557 Length of a(n) is n. %C A356557 Is the sequence infinite? The analogous sequences using bases 2, 3, 4, 5 and 7 are finite. %C A356557 Sequence terminates if and only if it contains a term of A125001. %H A356557 Michael S. Branicky, <a href="/A356557/b356557.txt">Table of n, a(n) for n = 1..1000</a> (terms 1..77 from Bartlomiej Pawlik) %e A356557 a(2) = 23 because the numbers 20, 21, 22 obtained from a(1) = 2 are composite and 23 is a prime. %e A356557 For n=6, starting from a(5)=23333 and appending a new rightmost digit gives 233330, 233331, ..., 233339 which are not primes. Inserting a digit second-rightmost gives 233303 and 233313 which are also not prime, and 233323 which is prime, so a(6) = 233323. %t A356557 k = 2; K = {k}; For[n = 1, n <= 20, n++, r = 0; For[p = IntegerLength[k] + 1, p >= 1, p--, If[r == 1, Break[]]; For[d = 0, d <= 9, d++, If[PrimeQ[ m = ToExpression[StringInsert[ToString[k], ToString[d], p]]], If[k != m, k = m, Print["FINITE"]]; AppendTo[K, k]; r = 1; Break[]]]]]; Print[K] (* _Samuel Harkness_, Sep 29 2022 *) %o A356557 (Python) %o A356557 from sympy import isprime %o A356557 from itertools import islice %o A356557 def anext(an): %o A356557 s = str(an) %o A356557 for k in range(len(s)+1): %o A356557 for c in "0123456789": %o A356557 w = s + c if k == 0 else s[:-k] + c + s[-k:] %o A356557 if isprime(int(w)): return int(w) %o A356557 def agen(an=2): %o A356557 while an != None: yield an; an = anext(an) %o A356557 print(list(islice(agen(), 21))) # _Michael S. Branicky_, Aug 12 2022 %Y A356557 Cf. A125001, A332603, A357436. %K A356557 nonn,base %O A356557 1,1 %A A356557 _Bartlomiej Pawlik_, Aug 12 2022