A382981 The smallest n-digit prime that turns composite at each step as its digits are successively appended, starting from the last.
2, 11, 101, 1019, 10007, 100043, 1000003, 10000019, 100000007, 1000000007, 10000000019, 100000000003, 1000000000039, 10000000000037, 100000000000031, 1000000000000037, 10000000000000061, 100000000000000003, 1000000000000000003, 10000000000000000051
Offset: 1
Examples
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.
Links
- Michael S. Branicky, Table of n, a(n) for n = 1..1000
Programs
-
Mathematica
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 *)
-
Python
from sympy import isprime, nextprime def c(s): # check if prime p's string of digits meets the concatenation condition return not any(isprime(int(s:=s+c)) for c in s[::-1]) def a(n): p = nextprime(10**(n-1)) while not c(str(p)): p = nextprime(p) return p print([a(n) for n in range(1, 21)]) # Michael S. Branicky, Apr 16 2025