login
Smallest prime obtained by sandwiching n between a number with identical digits, or 0 if no such prime exists. Primes of the form k n k where all the digits of k are identical.
8

%I #35 Nov 12 2020 12:33:46

%S 101,313,727,131,11411,151,777767777,373,181,191,9109,0,7127,331333,

%T 991499,1151,3163,1171,1181,9199,1201,112111,0,1231,7247,3253,

%U 7777777777267777777777,1111271111,11128111,1291,1301,3313,1321,0,3343,333533,1361,3373,1381

%N Smallest prime obtained by sandwiching n between a number with identical digits, or 0 if no such prime exists. Primes of the form k n k where all the digits of k are identical.

%C a(n) = 0 if n is a palindrome with even number of digits. Conjecture: No other term is zero.

%C The conjecture is false. a(231) = 0, a(420) = 0, a(n) = 0 if 11 divides n and n has an even number of digits. a(1414) has over 2000 digits. - _Chai Wah Wu_, Mar 31 2015

%H Chai Wah Wu, <a href="/A090287/b090287.txt">Table of n, a(n) for n = 0..365</a>

%H Chai Wah Wu, <a href="http://arxiv.org/abs/1503.08883">On a conjecture regarding primality of numbers constructed from prepending and appending identical digits</a>, arXiv:1503.08883 [math.NT], 2015.

%H <a href="/index/Pri#piden">Index entries for primes involving decimal expansion of n</a>

%t (* f(n) defined by _José de Jesús Camacho Medina_ in A010785. *)

%t lst={};f[m_]:=IntegerDigits[(m-9*Floor[(m-1)/9])*(10^Floor[(m+8)/9]-1)/9];

%t g[n_]:=FromDigits[Flatten[{f[m],IntegerDigits[n],f[m]}]];

%t Do[m=1;While[True,If[Mod[Length[IntegerDigits[n]],2]==0&&IntegerDigits[n]==Reverse[IntegerDigits[n]],

%t AppendTo[lst,0];Break[],If[PrimeQ[g[n]],AppendTo[lst,g[n]];Break[]]];m++],{n,25}];

%t lst (* _Ivan N. Ianakiev_, Mar 23 2015 *)

%o (Python)

%o from gmpy2 import is_prime, mpz, digits

%o def A090287(n,limit=2000):

%o ....sn = str(n)

%o ....if n in (231, 420, 759) or not (len(sn) % 2 or n % 11):

%o ........return 0

%o ....for i in range(1,limit+1):

%o ........for j in range(1,10,2):

%o ............si = digits(j,10)*i

%o ............p = mpz(si+sn+si)

%o ............if is_prime(p):

%o ................return int(p)

%o ....else:

%o ........return 'search limit reached.' # _Chai Wah Wu_, Mar 31 2015

%Y Cf. A010785, A338712.

%K base,nonn

%O 0,1

%A _Amarnath Murthy_, Nov 29 2003

%E a(0) from _Chai Wah Wu_, Mar 23 2015

%E a(26)-a(38) from _Chai Wah Wu_, Mar 24 2015