cp's OEIS Frontend

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.

A382981 The smallest n-digit prime that turns composite at each step as its digits are successively appended, starting from the last.

This page as a plain text file.
%I A382981 #22 Apr 16 2025 10:30:06
%S A382981 2,11,101,1019,10007,100043,1000003,10000019,100000007,1000000007,
%T A382981 10000000019,100000000003,1000000000039,10000000000037,
%U A382981 100000000000031,1000000000000037,10000000000000061,100000000000000003,1000000000000000003,10000000000000000051
%N A382981 The smallest n-digit prime that turns composite at each step as its digits are successively appended, starting from the last.
%H A382981 Michael S. Branicky, <a href="/A382981/b382981.txt">Table of n, a(n) for n = 1..1000</a>
%e A382981 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 A382981 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 A382981 (Python)
%o A382981 from sympy import isprime, nextprime
%o A382981 def c(s): # check if prime p's string of digits meets the concatenation condition
%o A382981     return not any(isprime(int(s:=s+c)) for c in s[::-1])
%o A382981 def a(n):
%o A382981     p = nextprime(10**(n-1))
%o A382981     while not c(str(p)): p = nextprime(p)
%o A382981     return p
%o A382981 print([a(n) for n in range(1, 21)]) # _Michael S. Branicky_, Apr 16 2025
%Y A382981 Cf. A003617, A382899.
%K A382981 nonn,base
%O A382981 1,1
%A A382981 _Jean-Marc Rebert_, Apr 11 2025