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-5 of 5 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

A070252 Number of n-digit palindromes.

Original entry on oeis.org

10, 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

Amarnath Murthy, May 06 2002

Keywords

Crossrefs

A variant of A050683, which is the principal entry for this sequence. Cf. A016115.
Partial sums give A070199.

Programs

  • Mathematica
    LinearRecurrence[{0,10},{10,9,90},25] (* Stefano Spezia, Jun 11 2022 *)
  • Python
    def A070252(n): return 10 if n==1 else 9*10**(n-1>>1) # Chai Wah Wu, Jul 30 2025

Formula

From Colin Barker, Aug 19 2013: (Start)
a(n) = 10*a(n-2) for n>3.
G.f.: x*(10*x^2-9*x-10) / (10*x^2-1). (End)
E.g.f.: x + 9*(cosh(sqrt(10)*x) - 1 + sqrt(10)*sinh(sqrt(10)*x))/10. - Stefano Spezia, Jun 11 2022

A050251 Number of palindromic primes less than 10^n.

Original entry on oeis.org

0, 4, 5, 20, 20, 113, 113, 781, 781, 5953, 5953, 47995, 47995, 401696, 401696, 3438339, 3438339, 30483565, 30483565, 269577430, 269577430, 2427668363, 2427668363, 22170468927, 22170468927, 202985860292, 202985860292
Offset: 0

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, 11. - Martin Renner, Apr 15 2006

Crossrefs

Partial sums of A016115.
Cf. A002113 (palindromes), A002385 (palindromic primes).

Programs

  • Python
    from _future_ import division
    from sympy import isprime
    def paloddgen(l,b=10): # generator of odd-length palindromes in base b of length <= 2*l
        if l > 0:
            yield 0
            for x in range(1,l+1):
                n = b**(x-1)
                n2 = n*b
                for y in range(n,n2):
                    k, m = y//b, 0
                    while k >= b:
                        k, r = divmod(k,b)
                        m = b*m + r
                    yield y*n + b*m + k
    def A050251(n):
        if n <= 1:
            return 4*n
        else:
            c = 1
            for i in paloddgen((n+1)//2):
                if isprime(i):
                    c += 1
            return c # Chai Wah Wu, Jan 05 2015

Formula

a(n) ~ A070199(n)/log(10^n) = 1/log(10^n)*Sum {k=1..n} 9*10^floor[(k-1)/2]. - Robert G. Wilson v, May 31 2009
a(2n) = a(2n-1) for n > 1. - Chai Wah Wu, Nov 21 2021

Extensions

More terms from Patrick De Geest, Aug 01 1999
2 more terms from Shyam Sunder Gupta, Feb 12 2006
2 more terms from Shyam Sunder Gupta, Mar 13 2009
a(23)-a(24) from Shyam Sunder Gupta, Oct 05 2013
Missing a(0) inserted by Chai Wah Wu, Nov 21 2021
a(25)-a(26) from Shyam Sunder Gupta, Dec 19 2024

A328332 Expansion of (1 + 4*x - 5*x^2 + 10*x^3) / ((1 - x) * (1 - 10*x^2)).

Original entry on oeis.org

1, 5, 10, 60, 110, 610, 1110, 6110, 11110, 61110, 111110, 611110, 1111110, 6111110, 11111110, 61111110, 111111110, 611111110, 1111111110, 6111111110, 11111111110, 61111111110, 111111111110, 611111111110, 1111111111110, 6111111111110, 11111111111110, 61111111111110, 111111111111110
Offset: 0

Views

Author

Ilya Gutkovskiy, Oct 12 2019

Keywords

Comments

Number of odd palindromes <= 10^n.

Crossrefs

Programs

  • Mathematica
    nmax = 28; CoefficientList[Series[(1 + 4 x - 5 x^2 + 10 x^3) / ((1 - x) (1 - 10 x^2)), {x, 0, nmax}], x]
    Join[{1}, LinearRecurrence[{1, 10, -10}, {5, 10, 60}, 28]]
  • PARI
    Vec((1 + 4*x - 5*x^2 + 10*x^3) / ((1 - x) * (1 - 10*x^2)) + O(x^30)) \\ Michel Marcus, Oct 13 2019

Formula

G.f.: (1 + 4*x - 5*x^2 + 10*x^3) / ((1 - x) * (1 - 10*x^2)).
a(n) = a(n-1) + 10*a(n-2) - 10*a(n-3). - Wesley Ivan Hurt, Aug 25 2022

A328333 Expansion of (1 + 4*x - 6*x^2) / ((1 - x) * (1 - 10*x^2)).

Original entry on oeis.org

1, 5, 9, 49, 89, 489, 889, 4889, 8889, 48889, 88889, 488889, 888889, 4888889, 8888889, 48888889, 88888889, 488888889, 888888889, 4888888889, 8888888889, 48888888889, 88888888889, 488888888889, 888888888889, 4888888888889, 8888888888889, 48888888888889, 88888888888889
Offset: 0

Views

Author

Ilya Gutkovskiy, Oct 12 2019

Keywords

Comments

Number of even palindromes < 10^n.

Crossrefs

Programs

  • Mathematica
    nmax = 28; CoefficientList[Series[(1 + 4 x - 6 x^2)/((1 - x) (1 - 10 x^2)), {x, 0, nmax}], x]
    LinearRecurrence[{1, 10, -10}, {1, 5, 9}, 29]
  • PARI
    Vec((1 + 4*x - 6*x^2) / ((1 - x) * (1 - 10*x^2)) + O(x^30)) \\ Michel Marcus, Oct 13 2019
Showing 1-5 of 5 results.