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-3 of 3 results.

A050683 Number of nonzero palindromes of length n.

Original entry on oeis.org

9, 9, 90, 90, 900, 900, 9000, 9000, 90000, 90000, 900000, 900000, 9000000, 9000000, 90000000, 90000000, 900000000, 900000000, 9000000000, 9000000000, 90000000000, 90000000000, 900000000000, 900000000000, 9000000000000
Offset: 1

Views

Author

Patrick De Geest, Aug 15 1999

Keywords

Comments

In general the number of base k palindromes with n digits is (k-1)*k^floor((n-1)/2). (See A117855 or A225367 for an explanation.) - Henry Bottomley, Aug 14 2000
This sequence does not count 0 as palindrome with 1 digit, see A070252 = (10,9,90,90,...) for the variant which does. - M. F. Hasler, Nov 16 2008

Crossrefs

Cf. A016116 for numbers of binary palindromes, A016115 for prime palindromes.
Cf. A117855 for the base 3 version, and A225367 for a variant.

Programs

  • GAP
    a:=[9,9];; for n in [3..30] do a[n]:=10*a[n-2]; od; a; # Muniru A Asiru, Oct 07 2018
    
  • Magma
    [9*10^Floor((n-1)/2): n in [1..30]]; // Vincenzo Librandi, Aug 16 2011
    
  • Maple
    seq(9*10^floor((n-1)/2),n=1..30); # Muniru A Asiru, Oct 07 2018
  • Mathematica
    With[{c=9*10^Range[0,20]},Riffle[c,c]] (* or *) LinearRecurrence[{0,10},{9,9},40] (* Harvey P. Dale, Dec 15 2013 *)
  • PARI
    A050683(n)=9*10^((n-1)\2) \\ M. F. Hasler, Nov 16 2008
    
  • PARI
    \\ using M. F. Hasler's is_A002113(n) from A002113
    is_A002113(n)={Vecrev(n=digits(n))==n}
    for(n=1,8,j=0;for(k=10^(n-1),10^n-1,if(is_A002113(k),j++));print1(j,", ")) \\ Hugo Pfoertner, Oct 03 2018
    
  • PARI
    is_palindrome(x)={my(d=digits(x));for(k=1,#d\2,if(d[k]!=d[#d+1-k],return(0)));return(1)}
    for(n=1,8,j=0;for(k=10^(n-1),10^n-1,if(is_palindrome(k),j++));print1(j,", ")) \\ Hugo Pfoertner, Oct 02 2018
    
  • PARI
    a(n) = if(n<3, 9, 10*a(n-2)); \\ Altug Alkan, Oct 03 2018
    
  • Python
    def A050683(n): return 9*10**(n-1>>1) # Chai Wah Wu, Jul 30 2025

Formula

a(n) = 9*10^floor((n-1)/2).
From Colin Barker, Apr 06 2012: (Start)
a(n) = 10*a(n-2).
G.f.: 9*x*(1+x)/(1-10*x^2). (End)
E.g.f.: 9*(cosh(sqrt(10)*x) + sqrt(10)*sinh(sqrt(10)*x) - 1)/10. - Stefano Spezia, Jun 11 2022

A016115 Number of prime palindromes with n digits.

Original entry on oeis.org

4, 1, 15, 0, 93, 0, 668, 0, 5172, 0, 42042, 0, 353701, 0, 3036643, 0, 27045226, 0, 239093865, 0, 2158090933, 0, 19742800564, 0, 180815391365, 0
Offset: 1

Views

Author

Keywords

Comments

Every palindrome with an even number of digits is divisible by 11 and therefore is composite (not prime). Hence there is only one palindromic prime with an even number of digits, namely 11 itself. - Martin Renner, Apr 15 2006

References

  • James J. Tattersall, Elementary Number Theory in Nine Chapters, Cambridge University Press, 1999, page 113.

Crossrefs

Cf. A002113 (palindromes), A002385 (palindromic primes), A040025 (bisection), A050251 (partial sums).

Programs

  • Maple
    # A016115 Gets numbers of base-10 palindromic primes with exactly d digits, 1 <= d <= 13 (say), in the list "lis"
    lis:=[4,1];
    for d from 3 to 13 do
    if d::even then
        lis:=[op(lis),0];
    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)]:
        ct:=0; for x in Res2 do if isprime(x) then ct:=ct+1; fi: od:
        lis:=[op(lis),ct];
    fi:
    lprint(d,lis);
    od:
    lis; # N. J. A. Sloane, Oct 18 2015
  • Mathematica
    A016115[n_] := Module[{i}, If[EvenQ[n] && n > 2, Return[0]]; Return[Length[Select[Range[10^(n - 1), 10^n - 1], # == IntegerReverse[#] && PrimeQ[#] &]]]];
    Table[A016115[n], {n, 6}] (* Robert Price, May 25 2019 *)
    (* -OR-  A less straightforward implementation, but more efficient in that the palindromes are constructed instead of testing every number in the range. *)
    A016115[n_] := Module[{c, f, t0, t1},
       If[n == 2, Return[1]];
       If[EvenQ[n], Return[0]];
       c = 0; t0 = 10^((n - 1)/2); t1 = t0*10;
       For[f = t0, f < t1, f++,
        If[n != 1 && MemberQ[{2,4,5,6,8}, Floor[f/t0]], f = f + t0 - 1; Continue[]];
        If[PrimeQ[f*t0 + IntegerReverse[Floor[f/10]]], c++]]; Return[c]];
    Table[A016115[n], {n, 1, 12}] (* Robert Price, May 25 2019 *)
  • PARI
    apply( {A016115(n)=if(n%2, (n<3)+vecsum([sum(k=i, i+n, (k*2-k%10)%3 && isprime(k*n+fromdigits(Vecrev(digits(k\10))))) | i<-[1, 3, 7, 9]*n=10^(n\2)]), n==2)}, [1..12]) \\ M. F. Hasler, Dec 19 2024
  • Python
    from sympy import isprime
    from itertools import product
    def pals(d, base=10): # all d-digit palindromes
        digits = "".join(str(i) for i in range(base))
        for p in product(digits, repeat=d//2):
            if d > 1 and p[0] == "0": continue
            left = "".join(p); right = left[::-1]
            for mid in [[""], digits][d%2]: yield int(left + mid + right)
    def a(n): return int(n==2) if n%2 == 0 else sum(isprime(p) for p in pals(n))
    print([a(n) for n in range(1, 13)]) # Michael S. Branicky, Jun 23 2021
    

Formula

a(2n) = 0 for n > 1. - Chai Wah Wu, Nov 21 2021

Extensions

Corrected and extended by Patrick De Geest, Jun 15 1998
a(17) = 27045226 was found by Martin Eibl (M.EIBL(AT)LINK-R.de) and independently by Warut Roonguthai and later confirmed by Carlos Rivera, in June 1998.
a(19) from Shyam Sunder Gupta, Feb 12 2006
a(21)-a(22) from Shyam Sunder Gupta, Mar 13 2009
a(23)-a(24) from Shyam Sunder Gupta, Oct 05 2013
a(25)-a(26) from Shyam Sunder Gupta, Dec 19 2024

A118064 Decimal expansion of the sum of the reciprocals of the palindromic primes A002385 (Honaker's constant).

Original entry on oeis.org

1, 3, 2, 3, 9, 8, 2, 1, 4, 6, 8, 0, 6
Offset: 1

Views

Author

Martin Renner, May 11 2006

Keywords

Comments

From Robert G. Wilson v, Nov 01 2010: (Start)
n \ sum to 10^n
02 1.267099567099567099567099567099567099567099567099567099567099567099567
03 1.320723244590290964212793334437872849720871258315369002493912638038324
05 1.323748402250648554164425746280035962754669829327727800040192015109270
07 1.323964105671202458016249150576217276147952428601889817773483085610332
09 1.323980718065525060936354534562000413901564393192688451911141729415146
11 1.323982026479475203850120990923294207966175748395470136325039323549015
13 1.323982136437462724794656629740867909978221153827990721566573347887836
15 1.323982145891606234777299440047139038371441916546100653011463101470839
17 1.323982146724859090645464845257681674740147563533254654075059843860490
19 1.323982146799188851138232927173756400348958236915409881890097448921521
21 1.323982146805857558347279363344557427339916178257233985191868031567947 (End)

Examples

			1.323982146806...
		

Crossrefs

Programs

  • Mathematica
    (* first obtain nextPalindrome from A007632 *) s = 1/11; c = 1; pp = 1; Do[ While[pp < 10^n, If[PrimeQ@ pp, c++; s = N[s + 1/pp, 64]]; pp = NextPalindrome@ pp]; If[ OddQ@ n, pp = 10^(n + 1); Print[{s, n, c}]], {n, 17}] (* Robert G. Wilson v, May 31 2009 *)
    generate[n_] := Block[{id = IntegerDigits@n, insert = {{0}, {1}, {2}, {3}, {4}, {5}, {6}, {7}, {8}, {9}}}, FromDigits@ Join[id, #, Reverse@ id] & /@ insert]; sm = N[Plus @@ (1/{2, 3, 5, 7, 11}), 64]; k = 1; Do [While[k < 10^n, sm = N[sm + Plus @@ (1/Select[ generate@k, PrimeQ]), 128]; k++ ]; Print[{2 n + 1, sm}], {n, 9}] (* Robert G. Wilson v, Nov 01 2010 *)

Formula

Equals Sum_{p} 1/p, where p ranges over the palindromic primes.

Extensions

Corrected by Eric W. Weisstein, May 14 2006
More terms from Robert G. Wilson v, Nov 01 2010
Entry revised by N. J. A. Sloane, May 05 2013
Showing 1-3 of 3 results.