login
a(1) = number of 1-digit primes (that is, 4: 2,3,5,7); then a(n) = number of distinct n-digit prime numbers obtained by alternately left- and right-concatenating a digit to the a(n-1) primes obtained in the previous iteration.
2

%I #50 Apr 11 2021 11:59:49

%S 4,11,20,53,51,100,63,76,42,43,20,13,4,4,1

%N a(1) = number of 1-digit primes (that is, 4: 2,3,5,7); then a(n) = number of distinct n-digit prime numbers obtained by alternately left- and right-concatenating a digit to the a(n-1) primes obtained in the previous iteration.

%C No 16-digit numbers can be obtained from the 15-digit number 889292677731979.

%H Prime Curios, <a href="https://primes.utm.edu/curios/page.php/889292677731979.html">889292677731979</a>

%e 1-digit 2-digit 3-digit 4-digit ... 15-digit

%e ---------------------------------------------------------------

%e 2

%e 3 13 131 2131

%e 6131

%e 137 2137

%e 3137

%e 9137

%e 139 4139

%e 23 233 5233

%e 8233

%e 239 2239

%e 9239

%e 43 431 5431

%e 8431

%e 9431

%e 433 1433

%e 3433

%e 7433

%e 9433

%e 439 1439

%e 9439

%e 53

%e 73 733 1733

%e 3733

%e 4733

%e 6733

%e 9733

%e 739 3739

%e 9739

%e 83 839 5839

%e 8839

%e 9839

%e 5

%e 7 17 173 6173

%e 9173

%e 179 2179

%e 5179

%e 8179

%e 37 373 1373

%e 3373

%e 4373

%e 6373

%e 379 6379

%e 47 479 5479

%e 9479

%e 67 673 3673

%e 4673

%e 6673

%e 7673

%e 677 2677 889292677731979

%e 3677

%e 8677

%e 9677

%e 97 971 2971

%e 6971

%e 8971

%e 977 6977

%e ---------------------------------------------------------------

%e a(1) = 4, a(2) = 11, a(3) = 20, a(4) = 53, ..., a(15)= 1.

%t Block[{b = 10, t}, t = Select[Range[b], CoprimeQ[#, b] &]; TakeWhile[Length /@ Fold[Function[{a, n}, Append[a, If[EvenQ[n], Join @@ Map[Function[k, Select[Map[Prepend[k, #] &, Range[9]], PrimeQ@ FromDigits[#, b] &]], Last[a]], Join @@ Map[Function[k, Select[Map[Append[k, #] &, t], PrimeQ@ FromDigits[#, b] &]], Last[a]]]]] @@ {#1, #2} &, {IntegerDigits[Prime@ Range@ PrimePi@ b, b]}, Range[2, 16]], # > 0 &]] (* _Michael De Vlieger_, Jan 20 2018 *)

%o (Python)

%o from sympy import isprime

%o def alst():

%o primes, alst = [2, 3, 5, 7], []

%o while len(primes) > 0:

%o alst.append(len(primes))

%o if len(alst)%2 == 1:

%o candidates = set(int(d+str(p)) for p in primes for d in "123456789")

%o else:

%o candidates = set(int(str(p)+d) for p in primes for d in "1379")

%o primes = [c for c in candidates if isprime(c)]

%o return alst

%o print(alst()) # _Michael S. Branicky_, Apr 11 2021

%Y Cf. A050986, A050987, A297960, A298048.

%K nonn,full,base,fini

%O 1,1

%A _Seiichi Manyama_, Jan 09 2018