login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A002385 Palindromic primes: prime numbers whose decimal expansion is a palindrome.
(Formerly M0670 N0247)
274

%I M0670 N0247 #158 May 31 2023 09:11:05

%S 2,3,5,7,11,101,131,151,181,191,313,353,373,383,727,757,787,797,919,

%T 929,10301,10501,10601,11311,11411,12421,12721,12821,13331,13831,

%U 13931,14341,14741,15451,15551,16061,16361,16561,16661,17471,17971,18181

%N Palindromic primes: prime numbers whose decimal expansion is a palindrome.

%C Every palindrome with an even number of digits is divisible by 11, so 11 is the only member of the sequence with an even number of digits. - _David Wasserman_, Sep 09 2004

%C This holds in any number base A006093(n), n>1. - _Lekraj Beedassy_, Mar 07 2005 and Dec 06 2009

%C The log-log plot shows the fairly regular structure of these numbers. - _T. D. Noe_, Jul 09 2013

%C Conjecture: The only primes with palindromic prime indices that are palindromic primes themselves are 3, 5 and 11. Tested for the primes with the first 8000000 palindromic prime indices. - _Ivan N. Ianakiev_, Oct 10 2014

%C Banks, Hart, and Sakata derive a nontrivial upper bound for the number of prime palindromes n <= x as x -> oo. It follows that almost all palindromes are composite. The results hold in any base. The authors use Weil's bound for Kloosterman sums. - _Jonathan Sondow_, Jan 02 2018

%C Number of terms < 100^k: 4, 20, 113, 781, 5953, 47995, 401698, ..., . - _Robert G. Wilson v_, Jan 03 2018

%D A. H. Beiler, Recreations in the Theory of Numbers, Dover, NY, 1964, p. 228.

%D N. J. A. Sloane, A Handbook of Integer Sequences, Academic Press, 1973 (includes this sequence).

%D N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).

%H N. J. A. Sloane, <a href="/A002385/b002385.txt">Table of n, a(n) for n = 1..47995 (all palindromic primes with fewer than 12 digits)</a>, Oct 14 2015, extending earlier b-files from T. D. Noe and A. Olah.

%H W. D. Banks, D. N. Hart, and M. Sakata, <a href="http://dx.doi.org/10.4310/MRL.2004.v11.n6.a10">Almost all palindromes are composite</a>, Math. Res. Lett., 11 No. 5-6 (2004), 853-868.

%H K. S. Brown, <a href="http://www.mathpages.com/home/kmath359.htm">On General Palindromic Numbers</a>

%H C. K. Caldwell, "Top Twenty" page, <a href="https://t5k.org/top20/page.php?id=53">Palindrome</a>

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

%H Lubomira Dvorakova, Stanislav Kruml, and David Ryzak, <a href="https://arxiv.org/abs/2008.06864">Antipalindromic numbers</a>, arXiv:2008.06864 [math.CO], 2020. Mentions this sequence.

%H Ernest G. Hibbs, <a href="https://www.proquest.com/openview/4012f0286b785cd732c78eb0fc6fce80">Component Interactions of the Prime Numbers</a>, Ph. D. Thesis, Capitol Technology Univ. (2022), see p. 33.

%H T. D. Noe, <a href="/A002385/a002385.jpg">Log-log plot of the first 401696 terms</a>

%H I. Peterson, Math Trek, <a href="http://web.archive.org/web/20130103135005/http://www.maa.org/mathland/mathtrek_5_10_99.html">Palindromic Primes</a>

%H Phakhinkon Phunphayap and Prapanpong Pongsriiam, <a href="https://arxiv.org/abs/1803.09621">Reciprocal sum of palindromes</a>, arXiv:1803.00161 [math.CA], 2018.

%H M. Shafer, <a href="http://www.egr.msu.edu/~shafermi/primes">First 401066 Palprimes</a> [Broken link]

%H Eric Weisstein's World of Mathematics, <a href="http://mathworld.wolfram.com/PalindromicNumber.html">Palindromic Number</a>

%H Eric Weisstein's World of Mathematics, <a href="http://mathworld.wolfram.com/PalindromicPrime.html">Palindromic Prime</a>

%H Eric Weisstein's World of Mathematics, <a href="http://mathworld.wolfram.com/IntegerSequencePrimes.html">Integer Sequence Primes</a>

%H Wikipedia, <a href="http://en.wikipedia.org/wiki/Palindromic_prime">Palindromic prime</a>

%H <a href="/index/Pac#palindromes">Index entries for sequences related to palindromes</a>

%F Intersection of A000040 (primes) and A002113 (palindromes).

%F A010051(a(n)) * A136522(a(n)) = 1. [_Reinhard Zumkeller_, Apr 11 2011]

%F Complement of A032350 in A002113. - _Jonathan Sondow_, Jan 02 2018

%p ff := proc(n) local i,j,k,s,aa,nn,bb,flag; s := n; aa := convert(s,string); nn := length(aa); bb := ``; for i from nn by -1 to 1 do bb := cat(bb,substring(aa,i..i)); od; flag := 0; for j from 1 to nn do if substring(aa,j..j)<>substring(bb,j..j) then flag := 1 fi; od; RETURN(flag); end; gg := proc(i) if ff(ithprime(i)) = 0 then RETURN(ithprime(i)) fi end;

%p rev:=proc(n) local nn, nnn: nn:=convert(n,base,10): add(nn[nops(nn)+1-j]*10^(j-1),j=1..nops(nn)) end: a:=proc(n) if n=rev(n) and isprime(n)=true then n else fi end: seq(a(n),n=1..20000); # rev is a Maple program to revert a number - _Emeric Deutsch_, Mar 25 2007

%p # A002385 Gets all base-10 palindromic primes with exactly d digits, in the list "Res"

%p d:=7; # (say)

%p if d=1 then Res:= [2,3,5,7]:

%p elif d=2 then Res:= [11]:

%p elif d::even then

%p Res:=[]:

%p else

%p m:= (d-1)/2:

%p Res2 := [seq(seq(n*10^(m+1)+y*10^m+digrev(n), y=0..9), n=10^(m-1)..10^m-1)]:

%p Res:=[]: for x in Res2 do if isprime(x) then Res:=[op(Res),x]; fi: od:

%p fi:

%p Res; # _N. J. A. Sloane_, Oct 18 2015

%t Select[ Prime[ Range[2100] ], IntegerDigits[#] == Reverse[ IntegerDigits[#] ] & ]

%t lst = {}; e = 3; Do[p = n*10^(IntegerLength[n] - 1) + FromDigits@Rest@Reverse@IntegerDigits[n]; If[PrimeQ[p], AppendTo[lst, p]], {n, 10^e - 1}]; Insert[lst, 11, 5] (* _Arkadiusz Wesolowski_, May 04 2012 *)

%t Join[{2,3,5,7,11},Flatten[Table[Select[Prime[Range[PrimePi[ 10^(2n)]+1, PrimePi[ 10^(2n+1)]]],# == IntegerReverse[#]&],{n,3}]]] (* The program uses the IntegerReverse function from Mathematica version 10 *) (* _Harvey P. Dale_, Apr 22 2016 *)

%t genPal[n_Integer, base_Integer: 10] := Block[{id = IntegerDigits[n, base], insert = Join[{{}}, {# - 1} & /@ Range[base]]}, FromDigits[#, base] & /@ (Join[id, #, Reverse@id] & /@ insert)]; k = 1; lst = {2, 3, 5, 7}; While[k < 19, p = Select[genPal[k], PrimeQ];

%t If[p != {}, AppendTo[lst, p]]; k++]; Flatten@ lst (* RGWv *)

%t Select[ Prime[ Range[2100]], PalindromeQ] (* _Jean-François Alcover_, Feb 17 2018 *)

%t NestList[NestWhile[NextPrime, #, ! PalindromeQ[#2] &, 2] &, 2, 41] (* _Jan Mangaldan_, Jul 01 2020 *)

%o (Haskell)

%o a002385 n = a002385_list !! (n-1)

%o a002385_list = filter ((== 1) . a136522) a000040_list

%o -- _Reinhard Zumkeller_, Apr 11 2011

%o (PARI) is(n)=n==eval(concat(Vecrev(Str(n))))&&isprime(n) \\ _Charles R Greathouse IV_, Nov 20 2012

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

%o (Python)

%o from itertools import chain

%o from sympy import isprime

%o A002385 = sorted((n for n in chain((int(str(x)+str(x)[::-1]) for x in range(1,10**5)),(int(str(x)+str(x)[-2::-1]) for x in range(1,10**5))) if isprime(n))) # _Chai Wah Wu_, Aug 16 2014

%o (Python)

%o from sympy import isprime

%o A002385 = [*filter(isprime, (int(str(x) + str(x)[-2::-1]) for x in range(10**5)))]

%o A002385.insert(4, 11) # _Yunhan Shi_, Mar 03 2023

%o (Sage)

%o [n for n in (2..18181) if is_prime(n) and Word(n.digits()).is_palindrome()] # _Peter Luschny_, Sep 13 2018

%o (GAP) Filtered([1..20000],n->IsPrime(n) and ListOfDigits(n)=Reversed(ListOfDigits(n))); # _Muniru A Asiru_, Mar 08 2019

%Y A007500 = this sequence union A006567.

%Y Subsequence of A188650; A188649(a(n)) = a(n); see A033620 for multiplicative closure. [_Reinhard Zumkeller_, Apr 11 2011]

%Y Cf. A016041, A029732, A069469, A117697, A046942, A032350 (Palindromic nonprime numbers).

%K nonn,base,nice,easy

%O 1,1

%A _N. J. A. Sloane_, _Simon Plouffe_

%E More terms from Larry Reeves (larryr(AT)acm.org), Oct 25 2000

%E Comment from A006093 moved here by _Franklin T. Adams-Watters_, Dec 03 2009

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified April 24 18:17 EDT 2024. Contains 371962 sequences. (Running on oeis4.)