OFFSET
1,1
COMMENTS
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
This holds in any number base A006093(n), n>1. - Lekraj Beedassy, Mar 07 2005 and Dec 06 2009
The log-log plot shows the fairly regular structure of these numbers. - T. D. Noe, Jul 09 2013
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
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
Number of terms < 100^k, k >= 1: 5, 20, 113, 781, 5953, 47995, 401698, .... - Robert G. Wilson v, Jan 03 2018, corrected by M. F. Hasler, Dec 19 2024
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 A016115(n) (number of prime palindromes with n digits) up to n = k. - M. F. Hasler, Dec 19 2024
REFERENCES
A. H. Beiler, Recreations in the Theory of Numbers, Dover, NY, 1964, p. 228.
N. J. A. Sloane, A Handbook of Integer Sequences, Academic Press, 1973 (includes this sequence).
N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).
LINKS
N. J. A. Sloane, Table of n, a(n) for n = 1..47995 (all palindromic primes with fewer than 12 digits), Oct 14 2015, extending earlier b-files from T. D. Noe and A. Olah.
W. D. Banks, D. N. Hart, and M. Sakata, Almost all palindromes are composite, Math. Res. Lett., 11 No. 5-6 (2004), 853-868.
K. S. Brown, On General Palindromic Numbers
C. K. Caldwell, "Top Twenty" page, Palindrome
Patrick De Geest, World!Of Palindromic Primes
Lubomira Dvorakova, Stanislav Kruml, and David Ryzak, Antipalindromic numbers, arXiv:2008.06864 [math.CO], 2020. Mentions this sequence.
Ernest G. Hibbs, Component Interactions of the Prime Numbers, Ph. D. Thesis, Capitol Technology Univ. (2022), see p. 33.
Dmytro S. Inosov and Emil Vlasák, Cryptarithmically unique terms in integer sequences, arXiv:2410.21427 [math.NT], 2024. See pp. 10, 18.
T. D. Noe, Log-log plot of the first 401696 terms
I. Peterson, Math Trek, Palindromic Primes
Phakhinkon Phunphayap and Prapanpong Pongsriiam, Reciprocal sum of palindromes, arXiv:1803.00161 [math.CA], 2018.
M. Shafer, First 401066 Palprimes
Eric Weisstein's World of Mathematics, Palindromic Number
Eric Weisstein's World of Mathematics, Palindromic Prime
Eric Weisstein's World of Mathematics, Integer Sequence Primes
Wikipedia, Palindromic prime
FORMULA
MAPLE
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;
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
# A002385 Gets all base-10 palindromic primes with exactly d digits, in the list "Res"
d:=7; # (say)
if d=1 then Res:= [2, 3, 5, 7]:
elif d=2 then Res:= [11]:
elif d::even then
Res:=[]:
else
m:= (d-1)/2:
Res2 := [seq(seq(n*10^(m+1)+y*10^m+digrev(n), y=0..9), n=10^(m-1)..10^m-1)]:
Res:=[]: for x in Res2 do if isprime(x) then Res:=[op(Res), x]; fi: od:
fi:
Res; # N. J. A. Sloane, Oct 18 2015
MATHEMATICA
Select[ Prime[ Range[2100] ], IntegerDigits[#] == Reverse[ IntegerDigits[#] ] & ]
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 *)
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 *)
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];
If[p != {}, AppendTo[lst, p]]; k++]; Flatten@ lst (* RGWv *)
Select[ Prime[ Range[2100]], PalindromeQ] (* Jean-François Alcover, Feb 17 2018 *)
NestList[NestWhile[NextPrime, #, ! PalindromeQ[#2] &, 2] &, 2, 41] (* Jan Mangaldan, Jul 01 2020 *)
PROG
(Haskell)
a002385 n = a002385_list !! (n-1)
a002385_list = filter ((== 1) . a136522) a000040_list
-- Reinhard Zumkeller, Apr 11 2011
(PARI) is(n)=n==eval(concat(Vecrev(Str(n))))&&isprime(n) \\ Charles R Greathouse IV, Nov 20 2012
(PARI) forprime(p=2, 10^5, my(d=digits(p, 10)); if(d==Vecrev(d), print1(p, ", "))); \\ Joerg Arndt, Aug 17 2014
(PARI) A002385_row(n)=select(is_A002113, primes([10^(n-1), 10^n])) \\ Terms with n digits. For larger n, better filter primes in palindromes. - M. F. Hasler, Dec 19 2024
(Python)
from itertools import chain
from sympy import isprime
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
(Python)
from sympy import isprime
A002385 = [*filter(isprime, (int(str(x) + str(x)[-2::-1]) for x in range(10**5)))]
A002385.insert(4, 11) # Yunhan Shi, Mar 03 2023
(Sage)
[n for n in (2..18181) if is_prime(n) and Word(n.digits()).is_palindrome()] # Peter Luschny, Sep 13 2018
(GAP) Filtered([1..20000], n->IsPrime(n) and ListOfDigits(n)=Reversed(ListOfDigits(n))); # Muniru A Asiru, Mar 08 2019
CROSSREFS
Subsequence of A188650; A188649(a(n)) = a(n); see A033620 for multiplicative closure. [Reinhard Zumkeller, Apr 11 2011]
Cf. A016115 (number of prime palindromes with n digits).
KEYWORD
nonn,base,nice,easy,changed
AUTHOR
EXTENSIONS
More terms from Larry Reeves (larryr(AT)acm.org), Oct 25 2000
Comment from A006093 moved here by Franklin T. Adams-Watters, Dec 03 2009
STATUS
approved