login
Smallest palindromic prime made up of 0's and p(n) 1's, where p(n) is the n-th prime = A000040(n) (or 0 when no such prime exists).
1

%I #10 Nov 06 2015 02:01:26

%S 11,0,100111001,110111011,1110111110111,10111101110111101,

%T 100111111111111111001,1111111111111111111,11111111111111111111111,

%U 1111110111111111111111110111111,11111101111111110101111111110111111

%N Smallest palindromic prime made up of 0's and p(n) 1's, where p(n) is the n-th prime = A000040(n) (or 0 when no such prime exists).

%C Smallest palindromic prime with digit sum A000040(n) and using only 0's and 1's. Subsequence of A158214.

%C Smallest palindromic prime with digit sum A000040(n) and using only 0's and 1's. Subsequence of A100580.(Sequence link edited). [_Lekraj Beedassy_, Jun 21 2009]

%H Chai Wah Wu, <a href="/A158215/b158215.txt">Table of n, a(n) for n = 1..168</a>

%o (Python)

%o from __future__ import division

%o from itertools import combinations

%o from sympy import prime, isprime

%o def A158215(n):

%o if n == 1:

%o return 11

%o if n == 2:

%o return 0

%o p2 = prime(n)//2

%o l = p2

%o while True:

%o for i in combinations(range(l),l-p2):

%o s = ['1']*l

%o for x in i:

%o s[x] = '0'

%o s = ''.join(s)

%o q = int(s+'1'+s[::-1])

%o if isprime(q):

%o return q

%o l += 1 # _Chai Wah Wu_, Nov 05 2015

%Y Cf. A157712

%Y Cf. A158214. [_Lekraj Beedassy_, Jun 21 2009]

%K nonn,base

%O 1,1

%A _Lekraj Beedassy_, Mar 13 2009