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-10 of 14 results. Next

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

A070199 Number of palindromes of length <= n.

Original entry on oeis.org

10, 19, 109, 199, 1099, 1999, 10999, 19999, 109999, 199999, 1099999, 1999999, 10999999, 19999999, 109999999, 199999999, 1099999999, 1999999999, 10999999999, 19999999999, 109999999999, 199999999999, 1099999999999, 1999999999999, 10999999999999, 19999999999999
Offset: 1

Views

Author

Keywords

Crossrefs

Partial sums of A070252.
Cf. A050250.

Programs

  • Mathematica
    LinearRecurrence[{1,10,-10},{10,19,109},30] (* Harvey P. Dale, Mar 18 2016 *)
  • PARI
    Vec(x*(10+9*x-10*x^2)/((1-x)*(1-10*x^2)) + O(x^40)) \\ Colin Barker, Mar 17 2017
    
  • Python
    def A070199(n): return 10**(n>>1)*(11 if n&1 else 2)-1 # Chai Wah Wu, Jul 30 2025

Formula

From Colin Barker, Jun 30 2012: (Start)
a(n) = a(n-1) + 10*a(n-2) - 10*a(n-3).
G.f.: x*(10 + 9*x - 10*x^2)/((1 - x)*(1 - 10*x^2)). (End)
a(n) = (-2*sqrt(10)+10^(n/2)*(11+2*sqrt(10)+(-1)^n*(-11+2*sqrt(10))))/(2*sqrt(10)). - Harvey P. Dale, Mar 18 2016
From Colin Barker, Mar 17 2017: (Start)
a(n) = 2^(n/2 + 1)*5^(n/2) - 1 for n even.
a(n) = 11*10^((n-1)/2) - 1 for n odd. (End)
a(n) = A050250(n) + 1. - Andrew Howroyd, Oct 28 2020
E.g.f.: 2*cosh(sqrt(10)*x) - cosh(x) - 1 - sinh(x) + 11*sinh(sqrt(10)*x)/sqrt(10). - Stefano Spezia, Jul 01 2023

A083816 10^n-th palindrome.

Original entry on oeis.org

1, 11, 919, 90109, 9001009, 900010009, 90000100009, 9000001000009, 900000010000009, 90000000100000009, 9000000001000000009, 900000000010000000009, 90000000000100000000009, 9000000000001000000000009, 900000000000010000000000009, 90000000000000100000000000009, 9000000000000001000000000000009
Offset: 0

Views

Author

Robert G. Wilson v, Jun 17 2003

Keywords

Crossrefs

Programs

  • Mathematica
    NextPalindrome[n_] := Block[{l = Floor[Log[10, n] + 1], idn = IntegerDigits[n]}, If[ Union[idn] == {9}, Return[n + 2], If[l < 2, Return[n + 1], If[ FromDigits[ Reverse[ Take[idn, Ceiling[l/2]]]] FromDigits[ Take[idn, -Ceiling[l/2]]], FromDigits[ Join[ Take[idn, Ceiling[l/2]], Reverse[ Take[idn, Floor[l/2]]]]], idfhn = FromDigits[ Take[idn, Ceiling[l/2]]] + 1; idp = FromDigits[ Join[ IntegerDigits[idfhn], Drop[Reverse[ IntegerDigits[idfhn]], Mod[l, 2]]]] ]]]]; p = NestList[ NextPalindrome, 1, 10^5]; Table[ p[[10^n]], {n, 0, 5}]

Formula

From Chai Wah Wu, Jun 13 2024: (Start)
a(n) = 111*a(n-1) - 1110*a(n-2) + 1000*a(n-3) for n > 4.
G.f.: (-8000*x^4 + 690*x^3 - 808*x^2 + 100*x - 1)/((x - 1)*(10*x - 1)*(100*x - 1)). (End)

Extensions

More terms from Ray Chandler, Jul 23 2003

A050684 Number of nonzero palindromes < 10^n and containing at least one digit '1'.

Original entry on oeis.org

1, 2, 20, 38, 290, 542, 3710, 6878, 44390, 81902, 509510, 937118, 5685590, 10434062, 62170310, 113906558, 669532790, 1225159022, 7125795110, 13026431198, 75132155990, 137237880782, 786189403910, 1435140927038
Offset: 1

Views

Author

Patrick De Geest, Aug 15 1999

Keywords

Examples

			Up to 10^2 we find two numbers 1 and 11.
		

Crossrefs

Programs

  • Mathematica
    Table[If[EvenQ[n], 2*(10^(n/2) - 9^(n/2)) , 2*(10^((n - 1)/2) - 9^((n - 1)/2)) + 9*10^((n - 1)/2) - 8*9^((n - 1)/2)], {n, 25}] (* or *) LinearRecurrence[{0, 19, 0, -90},{1, 2, 20, 38},25] (* G. C. Greubel, Oct 27 2016 *)

Formula

a(2n) = 2*(10^n - 9^n); a(2n + 1) = 2*(10^n - 9^n) + 9*10^n - 8*9^n. - David Wasserman, Feb 14 2002

Extensions

More terms from David Wasserman, Feb 14 2002

A050685 Number of nonzero palindromes < 10^n and containing at least one digit '0'.

Original entry on oeis.org

0, 0, 9, 18, 189, 360, 2799, 5238, 36189, 67140, 435699, 804258, 5021289, 9238320, 56191599, 103144878, 615724389, 1128303900, 6641519499, 12154735098, 70773675489, 129392615880, 746963079399, 1364533542918, 7822667714589
Offset: 1

Views

Author

Patrick De Geest, Aug 15 1999

Keywords

Examples

			Up to 10^4 we find 18 numbers -> 101, 202, ..., 909, 1001, 2002, ... and 9009.
		

Crossrefs

Programs

  • Magma
    [IsOdd(n) select (5+22*(10)^((n+1) div 2)-25*9^((n+1) div 2)) div 20 else (1+8*(10)^(n div 2)-9^((n div 2)+1)) div 4:n in [1..30]]; // Vincenzo Librandi, Oct 29 2016
  • Mathematica
    LinearRecurrence[{1,19,-19,-90,90},{0,0,9,18,189},25] (* or *) Table[If[OddQ[n], (5 + 22*(10)^((n + 1)/2) - 25*9^((n + 1)/2))/20, (1 + 8*(10)^(n/2) - 9^((n/2) + 1))/4], {n, 1, 10}] (* G. C. Greubel, Oct 27 2016 *)

Formula

G.f.: (9*x^2*(x+1))/((1-x)*(1 - 9*x^2)*(1 - 10*x^2)). - Maksym Voznyy (voznyy(AT)mail.ru), Jul 28 2009
From G. C. Greubel, Oct 27 2016: (Start)
a(n) = a(n-1) + 19*a(n-2) - 19*a(n-3) - 90*a(n-4) + 90*a(n-5).
a(n) = (1/(4*sqrt(10)))*( 4*sqrt(10)*(1 + (-1)^n)*(10)^(n/2) + 22*(1 - (-1)^n)*(10)^(n/2) + sqrt(10)*(1 + ((-1)^n - 4)*3^(n + 1)) ).
E.g.f.: (1/(4*sqrt(10)))*( sqrt(10)*(3*exp(-3*x) + exp(x) -12*exp(3*x)) + 44*sinh(sqrt(10)*x) + 8*sqrt(10)*cosh(sqrt(10)*x)).
a(2*n) = (1/4)*(1 + 8*(10)^n - 9^(1 + n)), n>=1.
a(2*n+1) = (1/20)*(5 + 22*(10)^(n+1) - 25*9^(n+1)), n>=0. (End)

Extensions

More terms from Michael Lugo (mlugo(AT)thelabelguy.com), Dec 22 1999
Corrected by T. D. Noe, Nov 08 2006

A117862 Number of palindromes (in base 3) below 3^n.

Original entry on oeis.org

0, 2, 4, 10, 16, 34, 52, 106, 160, 322, 484, 970, 1456, 2914, 4372, 8746, 13120, 26242, 39364, 78730, 118096, 236194, 354292, 708586, 1062880, 2125762, 3188644, 6377290, 9565936, 19131874, 28697812, 57395626, 86093440, 172186882, 258280324, 516560650, 774840976
Offset: 0

Views

Author

Martin Renner, May 02 2006

Keywords

Crossrefs

Cf. A050250.

Programs

  • Mathematica
    Table[If[OddQ[n], 4*3^((n - 1)/2) - 2, 2*3^(n/2) - 2], {n,25}] (* or *) LinearRecurrence[{1,3,-3},{2, 4, 10},25] (* G. C. Greubel, Oct 27 2016 *)
  • PARI
    apply( {A117862(n)=3^(n\2)<<(1+n%2)-2}, [0..44]) \\ M. F. Hasler, Jul 28 2021

Formula

a(n) = 4*3^((n-1)/2)-2 (n odd), 2*3^(n/2)-2 (n even).
G.f.: 2*x*(x+1) / ((x-1)*(3*x^2-1)). - Colin Barker, Feb 15 2013

Extensions

More terms from Colin Barker, Feb 15 2013
Extended to offset 0 by M. F. Hasler, Jul 28 2021

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

A117863 Number of palindromes (in base 4) below 4^n.

Original entry on oeis.org

3, 6, 18, 30, 78, 126, 318, 510, 1278, 2046, 5118, 8190, 20478, 32766, 81918, 131070, 327678, 524286, 1310718, 2097150, 5242878, 8388606, 20971518, 33554430, 83886078, 134217726, 335544318, 536870910, 1342177278, 2147483646, 5368709118, 8589934590
Offset: 1

Views

Author

Martin Renner, May 02 2006

Keywords

Crossrefs

Cf. A050250.

Programs

  • Mathematica
    Rest[CoefficientList[Series[3x (x+1)/((x-1)(2x-1)(2x+1)),{x,0,40}],x]] (* or *) LinearRecurrence[{1,4,-4},{3,6,18},40] (* Harvey P. Dale, May 09 2013 *)

Formula

a(n) = 5*4^((n-1)/2)-2 (n odd), 2*4^(n/2)-2 (n even).
G.f.: 3*x*(x+1) / ((x-1)*(2*x-1)*(2*x+1)). [Colin Barker, Feb 15 2013]
a(1)=3, a(2)=6, a(3)=18, a(n)=a(n-1)+4*a(n-2)-4*a(n-3). - Harvey P. Dale, May 09 2013

Extensions

More terms from Colin Barker, Feb 15 2013

A117864 Number of palindromes (in base 5) below 5^n.

Original entry on oeis.org

4, 8, 28, 48, 148, 248, 748, 1248, 3748, 6248, 18748, 31248, 93748, 156248, 468748, 781248, 2343748, 3906248, 11718748, 19531248, 58593748, 97656248, 292968748, 488281248, 1464843748, 2441406248, 7324218748, 12207031248, 36621093748, 61035156248
Offset: 1

Views

Author

Martin Renner, May 02 2006

Keywords

Crossrefs

Programs

  • Mathematica
    pal5s[n_]:=If[OddQ[n],6 5^((n-1)/2)-2,2 5^(n/2)-2]; Array[pal5s,40] (* or *) LinearRecurrence[{1,5,-5},{4,8,28},40] (* Harvey P. Dale, May 30 2012 *)
  • PARI
    Vec(4*x*(x+1)/((x-1)*(5*x^2-1)) + O(x^100)) \\ Colin Barker, Apr 26 2015

Formula

a(n) = 6*5^((n-1)/2)-2 (n odd), 2*5^(n/2)-2 (n even).
a(1)=4, a(2)=8, a(3)=28, a(n)=a(n-1)+5*a(n-2)-5*a(n-3). - Harvey P. Dale, May 30 2012
G.f.: 4*x*(x+1) / ((x-1)*(5*x^2-1)). - Colin Barker, Apr 26 2015
a(n) = 4*A238366(n-1). - Michel Marcus, Apr 26 2015
E.g.f.: 2*cosh(sqrt(5)*x) - 2*cosh(x) - 2*sinh(x) + 6*sinh(sqrt(5)*x)/sqrt(5). - Stefano Spezia, Aug 29 2025

Extensions

More terms from Harvey P. Dale, May 30 2012
Showing 1-10 of 14 results. Next