CINXE.COM
A002385 - OEIS
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> <html> <head> <link rel="stylesheet" href="/styles.css"> <meta name="format-detection" content="telephone=no"> <meta http-equiv="content-type" content="text/html; charset=utf-8"> <meta name=viewport content="width=device-width, initial-scale=1"> <meta name="keywords" content="OEIS,integer sequences,Sloane" /> <title>A002385 - OEIS</title> <link rel="search" type="application/opensearchdescription+xml" title="OEIS" href="/oeis.xml"> <script> var myURL = "\/A002385" function redir() { var host = document.location.hostname; if(host != "oeis.org" && host != "127.0.0.1" && !/^([0-9.]+)$/.test(host) && host != "localhost" && host != "localhost.localdomain") { document.location = "https"+":"+"//"+"oeis"+".org/" + myURL; } } function sf() { if(document.location.pathname == "/" && document.f) document.f.q.focus(); } </script> </head> <body bgcolor=#ffffff onload="redir();sf()"> <div class=loginbar> <div class=login> <a href="/login?redirect=%2fA002385">login</a> </div> </div> <div class=center><div class=top> <center> <div class=donors> The OEIS is supported by <a href="http://oeisf.org/#DONATE">the many generous donors to the OEIS Foundation</a>. </div> <div class=banner> <a href="/"><img class=banner border="0" width="600" src="/banner2021.jpg" alt="A002385 - OEIS"></a> </div> </center> </div></div> <div class=center><div class=pagebody> <div class=searchbarcenter> <form name=f action="/search" method="GET"> <div class=searchbargreet> <div class=searchbar> <div class=searchq> <input class=searchbox maxLength=1024 name=q value="" title="Search Query"> </div> <div class=searchsubmit> <input type=submit value="Search" name=go> </div> <div class=hints> <span class=hints><a href="/hints.html">Hints</a></span> </div> </div> <div class=searchgreet> (Greetings from <a href="/welcome">The On-Line Encyclopedia of Integer Sequences</a>!) </div> </div> </form> </div> <div class=sequence> <div class=space1></div> <div class=line></div> <div class=seqhead> <div class=seqnumname> <div class=seqnum> A002385 </div> <div class=seqname> Palindromic primes: prime numbers whose decimal expansion is a palindrome. <br><font size=-1>(Formerly M0670 N0247)</font> </div> </div> <div class=scorerefs> 282 </div> </div> <div> <div class=seqdatabox> <div class=seqdata>2, 3, 5, 7, 11, 101, 131, 151, 181, 191, 313, 353, 373, 383, 727, 757, 787, 797, 919, 929, 10301, 10501, 10601, 11311, 11411, 12421, 12721, 12821, 13331, 13831, 13931, 14341, 14741, 15451, 15551, 16061, 16361, 16561, 16661, 17471, 17971, 18181, 18481, 19391, 19891, 19991</div> <div class=seqdatalinks> (<a href="/A002385/list">list</a>; <a href="/A002385/graph">graph</a>; <a href="/search?q=A002385+-id:A002385">refs</a>; <a href="/A002385/listen">listen</a>; <a href="/history?seq=A002385">history</a>; <a href="/search?q=id:A002385&fmt=text">text</a>; <a href="/A002385/internal">internal format</a>) </div> </div> </div> <div class=entry> <div class=section> <div class=sectname>OFFSET</div> <div class=sectbody> <div class=sectline>1,1</div> </div> </div> <div class=section> <div class=sectname>COMMENTS</div> <div class=sectbody> <div class=sectline>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. - <a href="/wiki/User:David_Wasserman">David Wasserman</a>, Sep 09 2004</div> <div class=sectline>This holds in any number base <a href="/A006093" title="a(n) = prime(n) - 1.">A006093</a>(n), n>1. - <a href="/wiki/User:Lekraj_Beedassy">Lekraj Beedassy</a>, Mar 07 2005 and Dec 06 2009</div> <div class=sectline>The log-log plot shows the fairly regular structure of these numbers. - <a href="/wiki/User:T._D._Noe">T. D. Noe</a>, Jul 09 2013</div> <div class=sectline>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. - <a href="/wiki/User:Ivan_N._Ianakiev">Ivan N. Ianakiev</a>, Oct 10 2014</div> <div class=sectline>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. - <a href="/wiki/User:Jonathan_Sondow">Jonathan Sondow</a>, Jan 02 2018</div> <div class=sectline>Number of terms < 100^k, k >= 1: 5, 20, 113, 781, 5953, 47995, 401698, .... - <a href="/wiki/User:Robert_G._Wilson_v">Robert G. Wilson v</a>, Jan 03 2018, corrected by <a href="/wiki/User:M._F._Hasler">M. F. Hasler</a>, Dec 19 2024</div> <div class=sectline>Initially the above comment listed 4, 20, 113, ... which is the number of terms less than 10, 1000, 10^5, ..., i.e., up to 10^(2k-1), k >= 1. The number of terms < 10^k are the cumulative sums of <a href="/A016115" title="Number of prime palindromes with n digits.">A016115</a>(n) (number of prime palindromes with n digits) up to n = k. - <a href="/wiki/User:M._F._Hasler">M. F. Hasler</a>, Dec 19 2024</div> </div> </div> <div class=section> <div class=sectname>REFERENCES</div> <div class=sectbody> <div class=sectline>A. H. Beiler, Recreations in the Theory of Numbers, Dover, NY, 1964, p. 228.</div> <div class=sectline>N. J. A. Sloane, A Handbook of Integer Sequences, Academic Press, 1973 (includes this sequence).</div> <div class=sectline>N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).</div> </div> </div> <div class=section> <div class=sectname>LINKS</div> <div class=sectbody> <div class=sectline>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.</div> <div class=sectline>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.</div> <div class=sectline>K. S. Brown, <a href="http://www.mathpages.com/home/kmath359.htm">On General Palindromic Numbers</a></div> <div class=sectline>C. K. Caldwell, "Top Twenty" page, <a href="https://t5k.org/top20/page.php?id=53">Palindrome</a></div> <div class=sectline>Patrick De Geest, <a href="http://www.worldofnumbers.com/palpri.htm">World!Of Palindromic Primes</a></div> <div class=sectline>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.</div> <div class=sectline>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.</div> <div class=sectline>Dmytro S. Inosov and Emil Vlas谩k, <a href="https://arxiv.org/abs/2410.21427">Cryptarithmically unique terms in integer sequences</a>, arXiv:2410.21427 [math.NT], 2024. See pp. 10, 18.</div> <div class=sectline>T. D. Noe, <a href="/A002385/a002385.jpg">Log-log plot of the first 401696 terms</a></div> <div class=sectline>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></div> <div class=sectline>Phakhinkon Phunphayap and Prapanpong Pongsriiam, <a href="https://arxiv.org/abs/1803.09621">Reciprocal sum of palindromes</a>, arXiv:1803.00161 [math.CA], 2018.</div> <div class=sectline>M. Shafer, <a href="https://web.archive.org/web/20050212074127/http://www.egr.msu.edu/~shafermi/primes/">First 401066 Palprimes</a></div> <div class=sectline>Eric Weisstein's World of Mathematics, <a href="https://mathworld.wolfram.com/PalindromicNumber.html">Palindromic Number</a></div> <div class=sectline>Eric Weisstein's World of Mathematics, <a href="https://mathworld.wolfram.com/PalindromicPrime.html">Palindromic Prime</a></div> <div class=sectline>Eric Weisstein's World of Mathematics, <a href="https://mathworld.wolfram.com/IntegerSequencePrimes.html">Integer Sequence Primes</a></div> <div class=sectline>Wikipedia, <a href="http://en.wikipedia.org/wiki/Palindromic_prime">Palindromic prime</a></div> <div class=sectline><a href="/index/Pac#palindromes">Index entries for sequences related to palindromes</a></div> </div> </div> <div class=section> <div class=sectname>FORMULA</div> <div class=sectbody> <div class=sectline>Intersection of <a href="/A000040" title="The prime numbers.">A000040</a> (primes) and <a href="/A002113" title="Palindromes in base 10.">A002113</a> (palindromes).</div> <div class=sectline><a href="/A010051" title="Characteristic function of primes: 1 if n is prime, else 0.">A010051</a>(a(n)) * <a href="/A136522" title="a(n) = 1 if n is a palindrome, otherwise 0.">A136522</a>(a(n)) = 1. [<a href="/wiki/User:Reinhard_Zumkeller">Reinhard Zumkeller</a>, Apr 11 2011]</div> <div class=sectline>Complement of <a href="/A032350" title="Palindromic nonprime numbers.">A032350</a> in <a href="/A002113" title="Palindromes in base 10.">A002113</a>. - <a href="/wiki/User:Jonathan_Sondow">Jonathan Sondow</a>, Jan 02 2018</div> </div> </div> <div class=section> <div class=sectname>MAPLE</div> <div class=sectbody> <div class=sectline>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;</div> <div class=sectline>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 - <a href="/wiki/User:Emeric_Deutsch">Emeric Deutsch</a>, Mar 25 2007</div> <div class=sectline># <a href="/A002385" title="Palindromic primes: prime numbers whose decimal expansion is a palindrome.">A002385</a> Gets all base-10 palindromic primes with exactly d digits, in the list "Res"</div> <div class=sectline>d:=7; # (say)</div> <div class=sectline>if d=1 then Res:= [2, 3, 5, 7]:</div> <div class=sectline>elif d=2 then Res:= [11]:</div> <div class=sectline>elif d::even then</div> <div class=sectline> Res:=[]:</div> <div class=sectline>else</div> <div class=sectline> m:= (d-1)/2:</div> <div class=sectline> Res2 := [seq(seq(n*10^(m+1)+y*10^m+digrev(n), y=0..9), n=10^(m-1)..10^m-1)]:</div> <div class=sectline> Res:=[]: for x in Res2 do if isprime(x) then Res:=[op(Res), x]; fi: od:</div> <div class=sectline>fi:</div> <div class=sectline>Res; # <a href="/wiki/User:N._J._A._Sloane">N. J. A. Sloane</a>, Oct 18 2015</div> </div> </div> <div class=section> <div class=sectname>MATHEMATICA</div> <div class=sectbody> <div class=sectline>Select[ Prime[ Range[2100] ], IntegerDigits[#] == Reverse[ IntegerDigits[#] ] & ]</div> <div class=sectline>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] (* <a href="/wiki/User:Arkadiusz_Wesolowski">Arkadiusz Wesolowski</a>, May 04 2012 *)</div> <div class=sectline>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 *) (* <a href="/wiki/User:Harvey_P._Dale">Harvey P. Dale</a>, Apr 22 2016 *)</div> <div class=sectline>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];</div> <div class=sectline>If[p != {}, AppendTo[lst, p]]; k++]; Flatten@ lst (* RGWv *)</div> <div class=sectline>Select[ Prime[ Range[2100]], PalindromeQ] (* <a href="/wiki/User:Jean-Fran莽ois_Alcover">Jean-Fran莽ois Alcover</a>, Feb 17 2018 *)</div> <div class=sectline>NestList[NestWhile[NextPrime, #, ! PalindromeQ[#2] &, 2] &, 2, 41] (* <a href="/wiki/User:Jan_Mangaldan">Jan Mangaldan</a>, Jul 01 2020 *)</div> </div> </div> <div class=section> <div class=sectname>PROG</div> <div class=sectbody> <div class=sectline>(Haskell)</div> <div class=sectline>a002385 n = a002385_list !! (n-1)</div> <div class=sectline>a002385_list = filter ((== 1) . a136522) a000040_list</div> <div class=sectline>-- <a href="/wiki/User:Reinhard_Zumkeller">Reinhard Zumkeller</a>, Apr 11 2011</div> <div class=sectline>(PARI) is(n)=n==eval(concat(Vecrev(Str(n))))&&isprime(n) \\ <a href="/wiki/User:Charles_R_Greathouse_IV">Charles R Greathouse IV</a>, Nov 20 2012</div> <div class=sectline>(PARI) forprime(p=2, 10^5, my(d=digits(p, 10)); if(d==Vecrev(d), print1(p, ", "))); \\ <a href="/wiki/User:Joerg_Arndt">Joerg Arndt</a>, Aug 17 2014</div> <div class=sectline>(PARI) <a href="/A002385" title="Palindromic primes: prime numbers whose decimal expansion is a palindrome.">A002385</a>_row(n)=select(is_<a href="/A002113" title="Palindromes in base 10.">A002113</a>, primes([10^(n-1), 10^n])) \\ Terms with n digits. For larger n, better filter primes in palindromes. - <a href="/wiki/User:M._F._Hasler">M. F. Hasler</a>, Dec 19 2024</div> <div class=sectline>(Python)</div> <div class=sectline>from itertools import chain</div> <div class=sectline>from sympy import isprime</div> <div class=sectline><a href="/A002385" title="Palindromic primes: prime numbers whose decimal expansion is a palindrome.">A002385</a> = 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))) # <a href="/wiki/User:Chai_Wah_Wu">Chai Wah Wu</a>, Aug 16 2014</div> <div class=sectline>(Python)</div> <div class=sectline>from sympy import isprime</div> <div class=sectline><a href="/A002385" title="Palindromic primes: prime numbers whose decimal expansion is a palindrome.">A002385</a> = [*filter(isprime, (int(str(x) + str(x)[-2::-1]) for x in range(10**5)))]</div> <div class=sectline><a href="/A002385" title="Palindromic primes: prime numbers whose decimal expansion is a palindrome.">A002385</a>.insert(4, 11) # <a href="/wiki/User:Yunhan_Shi">Yunhan Shi</a>, Mar 03 2023</div> <div class=sectline>(Sage)</div> <div class=sectline>[n for n in (2..18181) if is_prime(n) and Word(n.digits()).is_palindrome()] # <a href="/wiki/User:Peter_Luschny">Peter Luschny</a>, Sep 13 2018</div> <div class=sectline>(GAP) Filtered([1..20000], n->IsPrime(n) and ListOfDigits(n)=Reversed(ListOfDigits(n))); # <a href="/wiki/User:Muniru_A_Asiru">Muniru A Asiru</a>, Mar 08 2019</div> </div> </div> <div class=section> <div class=sectname>CROSSREFS</div> <div class=sectbody> <div class=sectline><a href="/A007500" title="Primes whose reversal in base 10 is also prime (called "palindromic primes" by D. Wells, although that name usually refers t...">A007500</a> = this sequence union <a href="/A006567" title="Emirps (primes whose reversal is a different prime).">A006567</a>.</div> <div class=sectline>Subsequence of <a href="/A188650" title="Fixed points of A188649: numbers divisible by the reverse of all their divisors.">A188650</a>; <a href="/A188649" title="Least common multiple of reversals of divisors of n in decimal representation.">A188649</a>(a(n)) = a(n); see <a href="/A033620" title="Numbers all of whose prime factors are palindromes.">A033620</a> for multiplicative closure. [<a href="/wiki/User:Reinhard_Zumkeller">Reinhard Zumkeller</a>, Apr 11 2011]</div> <div class=sectline>Cf. <a href="/A016041" title="Primes that are palindromic in base 2 (but written here in base 10).">A016041</a>, <a href="/A029732" title="Palindromic primes in base 16 (or hexadecimal), but written here in base 10.">A029732</a>, <a href="/A069469" title="Numbers n such that prime(reversal(n)) = reversal(prime(n)). Ignore leading 0's.">A069469</a>, <a href="/A117697" title="Palindromic primes in base 2 (written in base 2).">A117697</a>, <a href="/A046942" title="Numbers k such that k and prime(k) are both palindromes.">A046942</a>, <a href="/A032350" title="Palindromic nonprime numbers.">A032350</a> (Palindromic nonprime numbers).</div> <div class=sectline>Cf. <a href="/A016115" title="Number of prime palindromes with n digits.">A016115</a> (number of prime palindromes with n digits).</div> <div class=sectline>Sequence in context: <a href="/A077652" title="Primes whose initial and terminal decimal digits are identical.">A077652</a> <a href="/A069217" title="Numbers n such that phi(n) + sigma(n) = n + reversal(n).">A069217</a> <a href="/A083139" title="Primes in A083137.">A083139</a> * <a href="/A088562" title="Palindromic primes using at most two distinct digits.">A088562</a> <a href="/A083712" title="Duplicate of A082806.">A083712</a> <a href="/A082806" title="Palindromes which are prime and the sum of the digits is also prime.">A082806</a></div> <div class=sectline>Adjacent sequences: <a href="/A002382" title="Numbers of the form (p^2 - 49)/120 where p is prime.">A002382</a> <a href="/A002383" title="Primes of form k^2 + k + 1.">A002383</a> <a href="/A002384" title="Numbers m such that m^2 + m + 1 is prime.">A002384</a> * <a href="/A002386" title="Primes (lower end) with record gaps to the next consecutive prime: primes p(k) where p(k+1) - p(k) exceeds p(j+1) - p(j) for...">A002386</a> <a href="/A002387" title="Least k such that H(k) > n, where H(k) is the harmonic number Sum_{i=1..k} 1/i.">A002387</a> <a href="/A002388" title="Decimal expansion of Pi^2.">A002388</a></div> </div> </div> <div class=section> <div class=sectname>KEYWORD</div> <div class=sectbody> <div class=sectline><span title="a sequence of nonnegative numbers">nonn</span>,<span title="dependent on base used for sequence">base</span>,<span title="an exceptionally nice sequence">nice</span>,<span title="it is very easy to produce terms of sequence">easy</span>,<span title="edited within the last two weeks">changed</span></div> </div> </div> <div class=section> <div class=sectname>AUTHOR</div> <div class=sectbody> <div class=sectline><a href="/wiki/User:N._J._A._Sloane">N. J. A. Sloane</a>, <a href="/wiki/User:Simon_Plouffe">Simon Plouffe</a></div> </div> </div> <div class=section> <div class=sectname>EXTENSIONS</div> <div class=sectbody> <div class=sectline>More terms from Larry Reeves (larryr(AT)acm.org), Oct 25 2000</div> <div class=sectline>Comment from <a href="/A006093" title="a(n) = prime(n) - 1.">A006093</a> moved here by <a href="/wiki/User:Franklin_T._Adams-Watters">Franklin T. Adams-Watters</a>, Dec 03 2009</div> </div> </div> <div class=section> <div class=sectname>STATUS</div> <div class=sectbody> <div class=sectline>approved</div> </div> </div> </div> <div class=space10></div> </div> </div></div> <p> <div class=footerpad></div> <div class=footer> <center> <div class=bottom> <div class=linksbar> <a href="/">Lookup</a> <a href="/wiki/Welcome"><font color="red">Welcome</font></a> <a href="/wiki/Main_Page"><font color="red">Wiki</font></a> <a href="/wiki/Special:RequestAccount">Register</a> <a href="/play.html">Music</a> <a href="/plot2.html">Plot 2</a> <a href="/demo1.html">Demos</a> <a href="/wiki/Index_to_OEIS">Index</a> <a href="/webcam">WebCam</a> <a href="/Submit.html">Contribute</a> <a href="/eishelp2.html">Format</a> <a href="/wiki/Style_Sheet">Style Sheet</a> <a href="/transforms.html">Transforms</a> <a href="/ol.html">Superseeker</a> <a href="/recent">Recents</a> </div> <div class=linksbar> <a href="/community.html">The OEIS Community</a> </div> <div class=linksbar> Maintained by <a href="http://oeisf.org">The OEIS Foundation Inc.</a> </div> <div class=dbinfo>Last modified February 26 21:14 EST 2025. Contains 381238 sequences.</div> <div class=legal> <a href="/wiki/Legal_Documents">License Agreements, Terms of Use, Privacy Policy</a> </div> </div> </center> </div> </body> </html>