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.

A115941 a(n) is the least prime whose representation contains a palindromic substring of length n.

This page as a plain text file.
%I A115941 #10 Feb 12 2021 08:20:20
%S A115941 2,11,101,11113,10301,1011013,1003001,100110013,100030001,10000000019,
%T A115941 10000500001,1000011000017,1000008000001,100000440000011,
%U A115941 100000323000001,10000001100000011,10000000500000001,1000000011000000019,1000000008000000001,100000000660000000013
%N A115941 a(n) is the least prime whose representation contains a palindromic substring of length n.
%H A115941 Michael S. Branicky, <a href="/A115941/b115941.txt">Table of n, a(n) for n = 1..25</a>
%e A115941 a(6)=1011013 since it is the least prime that contains a palindromic substring (101101) of length 6.
%o A115941 (Python)
%o A115941 from sympy import isprime
%o A115941 from itertools import product
%o A115941 def pals_to_test(n, odd=True):
%o A115941   if n <= 2: yield [2, 11][n-1]
%o A115941   if odd: ruled_out = "024568" # can't be even or multiple of 5
%o A115941   else: ruled_out = "0"
%o A115941   midrange = [[""], [str(i) for i in range(10)]]
%o A115941   for p in product("0123456789", repeat=n//2):
%o A115941     left = "".join(p)
%o A115941     if len(left):
%o A115941       if left[0] in ruled_out: continue
%o A115941     for middle in midrange[n%2]:
%o A115941         out = left+middle+left[::-1]
%o A115941         if odd: yield out
%o A115941         else:
%o A115941           for last in "1379": yield out+last
%o A115941 def a(n):
%o A115941   palsgen = pals_to_test(n, n%2 == 1)
%o A115941   while True:
%o A115941     strpal = next(palsgen)
%o A115941     pal = int(strpal)
%o A115941     if isprime(pal): return pal
%o A115941 print([a(n) for n in range(1, 18)]) # _Michael S. Branicky_, Feb 11 2021
%Y A115941 Cf. A056732.
%K A115941 nonn,base
%O A115941 1,1
%A A115941 _Giovanni Resta_, Feb 06 2006
%E A115941 a(18) and beyond from _Michael S. Branicky_, Feb 11 2021