cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

Showing 1-6 of 6 results.

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

Original entry on oeis.org

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
Offset: 1

Views

Author

Keywords

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
It follows from the above conjecture that 2 is the only k such that k, prime(k), prime(m) = k + prime(k) and m are all palindromic primes. - Ivan N. Ianakiev, Mar 17 2025
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.
  • Paulo Ribenboim, The Little Book of Bigger Primes, Springer-Verlag NY 2004. See pp. 120-121.
  • 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).

Crossrefs

A007500 = this sequence union A006567.
Subsequence of A188650; A188649(a(n)) = a(n); see A033620 for multiplicative closure. [Reinhard Zumkeller, Apr 11 2011]
Cf. A016041, A029732, A069469, A117697, A046942, A032350 (Palindromic nonprime numbers).
Cf. A016115 (number of prime palindromes with n digits).

Programs

  • GAP
    Filtered([1..20000],n->IsPrime(n) and ListOfDigits(n)=Reversed(ListOfDigits(n))); # Muniru A Asiru, Mar 08 2019
  • Haskell
    a002385 n = a002385_list !! (n-1)
    a002385_list = filter ((== 1) . a136522) a000040_list
    -- Reinhard Zumkeller, Apr 11 2011
    
  • 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 *)
  • 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
    
  • Python
    from sympy import isprime
    from itertools import count, islice, product
    def A002385gen(): # generator of palprimes
        yield from [2, 3, 5, 7, 11]
        for d in count(3, 2):
            for last in "1379":
                for p in product("0123456789", repeat=d//2-1):
                    left = "".join(p)
                    for mid in [[""], "0123456789"][d&1]:
                        t = int(last + left + mid + left[::-1] + last)
                        if isprime(t):
                            yield t
    print(list(islice(A002385gen(), 46))) # Michael S. Branicky, Apr 13 2025
    
  • Sage
    [n for n in (2..18181) if is_prime(n) and Word(n.digits()).is_palindrome()] # Peter Luschny, Sep 13 2018
    

Formula

Intersection of A000040 (primes) and A002113 (palindromes).
A010051(a(n)) * A136522(a(n)) = 1. [Reinhard Zumkeller, Apr 11 2011]
Complement of A032350 in A002113. - Jonathan Sondow, Jan 02 2018

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

A046485 Sum of first n palindromic primes A002385.

Original entry on oeis.org

2, 5, 10, 17, 28, 129, 260, 411, 592, 783, 1096, 1449, 1822, 2205, 2932, 3689, 4476, 5273, 6192, 7121, 17422, 27923, 38524, 49835, 61246, 73667, 86388, 99209, 112540, 126371, 140302, 154643, 169384, 184835, 200386, 216447, 232808, 249369, 266030, 283501
Offset: 1

Views

Author

Patrick De Geest, Sep 15 1998

Keywords

Comments

The subsequence of prime partial sum of palindromic primes begins: 2, 5, 17, 5273, 7121, 154643, 283501. What is the smallest nontrivial (i.e., multidigit) palindromic prime partial sum of palindromic primes? [Jonathan Vos Post, Feb 07 2010]

Crossrefs

Programs

  • Mathematica
    t = {}; b = 10; Do[p = Prime[n]; i = IntegerDigits[p, b]; If[i == Reverse[i], AppendTo[t, p];(*Print[p.FromDigits[i]]*)], {n, 4000}]; Accumulate[t] (* Vladimir Joseph Stephan Orlovsky, Feb 23 2012 *)
    Accumulate[Select[Prime[Range[10000]],IntegerDigits[#]==Reverse[ IntegerDigits[#]]&]] (* Harvey P. Dale, Aug 10 2013 *)

Formula

a(n) = Sum_{i=1..n} A002385(i) = Sum_{i=1..n} {p prime and R(p) = p, i.e., primes whose decimal expansion is a palindrome}. [Jonathan Vos Post, Feb 07 2010]

Extensions

Offset set to 1 by R. J. Mathar, Feb 21 2010

A230820 Table, read by antidiagonals, of palindromic primes in base b expressed in decimal.

Original entry on oeis.org

3, 2, 5, 2, 13, 7, 2, 3, 23, 17, 2, 3, 5, 151, 31, 2, 3, 31, 17, 173, 73, 2, 3, 5, 41, 29, 233, 107, 2, 3, 5, 7, 67, 59, 757, 127, 2, 3, 5, 71, 37, 83, 257, 937, 257, 2, 3, 5, 7, 107, 43, 109, 373, 1093, 313, 2, 3, 5, 7, 73, 157, 61, 701, 409, 1249, 443
Offset: 1

Views

Author

Robert G. Wilson v, Oct 30 2013

Keywords

Examples

			\r
b\
.2.3...5...7...17...31...73..107..127...257...313...443..1193..1453..1571.=A016041
.3.2..13..23..151..173..233..757..937..1093..1249..1429..1487..1667..1733.=A029971
.4.2...3...5...17...29...59..257..373...409...461...509...787...839...887.=A029972
.5.2...3..31...41...67...83..109..701...911..1091..1171..1277..1327..1667.=A029973
.6.2...3...5....7...37...43...61...67...191...197..1297..1627..1663..1699.=A029974
.7.2...3...5...71..107..157..257..271...307..2549..2647..2801..3347..3697.=A029975
.8.2...3...5....7...73...89...97..113...211...227...251...349...373...463.=A029976
.9.2...3...5....7..109..127..173..191...227...337...373...419...601...619.=A029977
10.2...3...5....7...11..101..131..151...181...191...313...353...373...383.=A002385
11.2...3...5....7..199..277..421..443...499...521...587...643...709...743.=A029978
12.2...3...5....7...11...13..157..181...193...229...241...277...761...773.=A029979
...
inf..2..3..5..7..11..13..17..19..23..29..31..37..41..43..47..53..59..61...=A000040
		

Crossrefs

Programs

  • Maple
    A230820 := proc(b,n)
        option remember;
        local a,dgs ;
        if n = 1 then
            if b = 2 then
                return 3;
            else
                return 2;
            end if;
        else
            for a from procname(b,n-1)+1 do
                if isprime(a) then
                    ispal := true ;
                    dgs := convert(a,base,b) ;
                    for i from 1 to nops(dgs)/2 do
                        if op(i,dgs) <> op(-i,dgs) then
                            ispal := false;
                        end if;
                    end do:
                    if ispal then
                        return a;
                    end if;
                end if;
            end do:
        end if;
    end proc:
    for b from 2 to 9 do
        for n from 1 to 9 do
            printf("%3d ",A230820(b,n)) ;
        end do:
        printf("\n") ;
    end do; # R. J. Mathar, Feb 16 2014
  • Mathematica
    palQ[n_Integer, base_Integer] := Module[{idn = IntegerDigits[ n, base]}, idn == Reverse@ idn]; Table[Select[Prime@Range@500, palQ[#, k + 1] &][[b - k + 1]], {b, 11}, {k, b, 1, -1}] // Flatten

A256090 Non-palindromic balanced primes in base 16.

Original entry on oeis.org

6451, 7717, 8513, 8963, 9601, 10501, 10867, 11317, 11411, 12227, 13829, 14561, 15461, 15733, 16183, 16529, 16979, 18517, 19333, 19427, 19699, 20149, 20233, 20327, 22483, 22567, 23027, 23561, 23833, 25717, 26083, 26261, 26711, 27077, 27527, 27799, 27893, 28867, 29411, 29683, 30133, 30677, 30949, 31033, 31849
Offset: 1

Views

Author

M. F. Hasler, Mar 14 2015

Keywords

Comments

Here a number is called balanced if the sum of digits weighted by their arithmetic distance from the "center" is zero. Palindromic primes (A029732 in base 16) are trivially balanced, therefore they are excluded here.
These are the primes in A256080. This is the hexadecimal variant of the decimal version A256076 suggested by Eric Angelini.

Crossrefs

Programs

  • PARI
    is(n,b=16,d=digits(n,b),o=(#d+1)/2)=!(vector(#d,i,i-o)*d~)&&d!=Vecrev(d)&&isprime(n)

A182231 Primes that are palindromic in base 32.

Original entry on oeis.org

2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 1153, 1217, 1249, 1409, 1601, 1697, 1889, 2017, 3203, 3299, 3331, 3491, 3779, 3907, 4003, 5189, 5381, 5413, 5477, 5573, 5669, 5701, 5861, 6053, 7207, 7559, 7591, 7687, 7879, 8039, 8167, 9257, 9769, 9833, 9929, 11467
Offset: 1

Views

Author

Alex Ratushnyak, Apr 19 2012

Keywords

Examples

			1153_10 = 141_32. - _Jon E. Schoenfield_, Apr 10 2021
		

Crossrefs

Programs

  • Mathematica
    b = 32; lst = {}; Do[p = Prime[n]; If[IntegerDigits[p, b] == Reverse[IntegerDigits[p, b]], AppendTo[lst, p]], {n, 2000}]; lst (* T. D. Noe, Apr 19 2012 *)

A046484 Primes that are palindromic in bases 10 and 16.

Original entry on oeis.org

2, 3, 5, 7, 11, 353, 787, 94049, 98689, 190080091, 3405684865043, 397922151229793
Offset: 1

Views

Author

Keywords

Comments

Intersection of A002385 and A029732. - Michel Marcus, Jun 09 2013

Examples

			787_10 = 313_16. - _Jon E. Schoenfield_, Apr 10 2021
		

Crossrefs

Programs

  • PARI
    ispal(v) = {for(i=1, #v\2, if (v[i] != v[#v-i+1], return(0));); return(1);}; lista(nn) = {forprime(p=2, nn, if (ispal(digits(p, 10)) && ispal(digits(p, 16)), print1(p, ", ")););}  \\ Michel Marcus, Jun 09 2013
Showing 1-6 of 6 results.