login
Palindromic primes in base 8.
11

%I #20 Mar 05 2017 13:21:48

%S 2,3,5,7,73,89,97,113,211,227,251,349,373,463,479,487,503,4289,4481,

%T 4937,5393,5521,5657,5849,6761,7537,7993,12547,12611,12739,13003,

%U 13259,13331,13523,14107,14563,14627,14891,15083,15667,15731,15859

%N Palindromic primes in base 8.

%H Chai Wah Wu, <a href="/A029976/b029976.txt">Table of n, a(n) for n = 1..15000</a>

%H Patrick De Geest, <a href="http://www.worldofnumbers.com/palpri.htm">World!Of Palindromic Primes</a>

%t palQ[n_, b_:10] := Module[{idn = IntegerDigits[n, b]}, idn == Reverse[idn]]; Select[Prime[Range[2000]], palQ[#, 8] &] (* _Harvey P. Dale_, Dec 23 2013 *)

%o (Python)

%o from itertools import chain

%o from sympy import isprime

%o from gmpy2 import digits

%o A029976 = sorted((n for n in chain((int(digits(x,8)+digits(x,8)[::-1],8) for x in range(1,8**6)),(int(digits(x,8)+digits(x,8)[-2::-1],8) for x in range(1,8**6))) if isprime(n)))

%o # _Chai Wah Wu_, Aug 16 2014

%o (PARI) forprime(p=2,10^4, my(d=digits(p,8)); if(d==Vecrev(d),print1(p,", "))); \\ _Joerg Arndt_, Aug 17 2014

%Y Cf. A006341.

%K nonn,base

%O 1,1

%A _Patrick De Geest_