%I #22 Apr 16 2025 10:30:06
%S 2,11,101,1019,10007,100043,1000003,10000019,100000007,1000000007,
%T 10000000019,100000000003,1000000000039,10000000000037,
%U 100000000000031,1000000000000037,10000000000000061,100000000000000003,1000000000000000003,10000000000000000051
%N The smallest n-digit prime that turns composite at each step as its digits are successively appended, starting from the last.
%H Michael S. Branicky, <a href="/A382981/b382981.txt">Table of n, a(n) for n = 1..1000</a>
%e a(4) = 1019, because 1019 is prime and 10199 = 7 * 31 * 47, 101991 = 3 * 33997, 1019910 = 2 * 3 * 5 * 33997 and 10199101 = 11 * 927191 are composite, while no smaller 4-digit prime exhibits this property.
%t ok[p_] := Block[{d = IntegerDigits@p}, d = Join[d, Reverse@ d]; And @@ CompositeQ /@ (FromDigits[d[[;; #]]] & /@ Range[Length[d]/2 + 1, Length@d])]; a[n_] := Block[{p = NextPrime[10^(n-1)]}, While[! ok[p], p = NextPrime@p]; p]; Array[a, 20] (* _Giovanni Resta_, Apr 11 2025 *)
%o (Python)
%o from sympy import isprime, nextprime
%o def c(s): # check if prime p's string of digits meets the concatenation condition
%o return not any(isprime(int(s:=s+c)) for c in s[::-1])
%o def a(n):
%o p = nextprime(10**(n-1))
%o while not c(str(p)): p = nextprime(p)
%o return p
%o print([a(n) for n in range(1, 21)]) # _Michael S. Branicky_, Apr 16 2025
%Y Cf. A003617, A382899.
%K nonn,base
%O 1,1
%A _Jean-Marc Rebert_, Apr 11 2025