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 16 results. Next

A050250 Number of nonzero palindromes less than 10^n.

Original entry on oeis.org

9, 18, 108, 198, 1098, 1998, 10998, 19998, 109998, 199998, 1099998, 1999998, 10999998, 19999998, 109999998, 199999998, 1099999998, 1999999998, 10999999998, 19999999998, 109999999998, 199999999998, 1099999999998, 1999999999998, 10999999999998
Offset: 1

Views

Author

Eric W. Weisstein, Dec 11 1999

Keywords

Crossrefs

Programs

  • Maple
    A050250List := proc(len);  local s, egf, ser; s:= 11/(2*sqrt(10));
    egf := -2*exp(x) + (1-s)*exp(-sqrt(10)*x) + (1+s)*exp(sqrt(10)*x);
    ser := series(egf, x, len+2): seq(simplify(n!*coeff(ser,x,n)), n = 1..len) end:
    A050250List(25); # Peter Luschny, Jun 11 2022 after Stefano Spezia
  • Mathematica
    LinearRecurrence[{1,10,-10},{9,18,108},30] (* Harvey P. Dale, Jan 29 2012 *)
    CoefficientList[Series[2Cosh[Sqrt[10]x]-2(Cosh[x]+Sinh[x])+11Sinh[Sqrt[10]x]/Sqrt[10],{x,0,25}],x]Table[n!,{n,0,25}] (* Stefano Spezia, Jun 11 2022 *)
  • PARI
    a(n)=10^(n\2)*(13-9*(-1)^n)/2-2 \\ Charles R Greathouse IV, Jun 25 2017
    
  • Python
    def a(n):
      m = 10 ** (n >> 1)
      if n & 1 == 0:
        return (m - 1) << 1
      else:
        return (11 * m) - 2 # DarĂ­o Clavijo, Oct 16 2023

Formula

a(2*k) = 2*10^k - 2, a(2*k + 1) = 11*10^k - 2. - Sascha Kurz, Apr 14 2002
From Jonathan Vos Post, Jun 18 2008: (Start)
a(n) = Sum_{i=1..n} A050683(i).
a(n) = Sum_{i=1..n} 9*10^floor((i-1)/2).
a(n) = 9*Sum_{i=1..n} 10^floor((i-1)/2). (End)
From Bruno Berselli, Feb 15 2011: (Start)
G.f.: 9*x*(1+x)/((1-x)*(1-10*x^2)).
a(n) = (1/2)*10^((2*n + (-1)^n - 1)/4)*(13 - 9*(-1)^n) - 2. (End)
a(1)=9, a(2)=18, a(3)=108; for n>3, a(n) = a(n-1) + 10*a(n-2) - 10*a(n-3). - Harvey P. Dale, Jan 29 2012
a(n) = 10*a(n-2) + 18. - R. J. Mathar, Nov 07 2015
E.g.f.: 2*cosh(sqrt(10)*x) - 2*(cosh(x) + sinh(x)) + 11*sinh(sqrt(10)*x)/sqrt(10). - Stefano Spezia, Jun 11 2022

Extensions

More terms from Patrick De Geest, Dec 15 1999
a(24)-a(25) from Jonathan Vos Post, Jun 18 2008

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

A117855 Number of nonzero palindromes of length n (in base 3).

Original entry on oeis.org

2, 2, 6, 6, 18, 18, 54, 54, 162, 162, 486, 486, 1458, 1458, 4374, 4374, 13122, 13122, 39366, 39366, 118098, 118098, 354294, 354294, 1062882, 1062882, 3188646, 3188646, 9565938, 9565938, 28697814, 28697814, 86093442, 86093442, 258280326, 258280326, 774840978
Offset: 1

Views

Author

Martin Renner, May 02 2006

Keywords

Comments

See A225367 for the sequence that counts all base 3 palindromes, including 0 (and thus also the number of n-digit terms in A006072). -- A nonzero palindrome of length L=2k-1 or of length L=2k is determined by the first k digits, which then determine the last k digits by symmetry. Since the first digit cannot be 0, there are 2*3^(k-1) possibilities. - M. F. Hasler, May 05 2013
From Gus Wiseman, Oct 18 2023: (Start)
Also the number of subsets of {1..n} with n not the sum of two subset elements (possibly the same). For example, the a(0) = 1 through a(4) = 6 subsets are:
{} {} {} {} {}
{1} {2} {1} {1}
{2} {3}
{3} {4}
{1,3} {1,4}
{2,3} {3,4}
For subsets with no subset summing to n we have A365377.
Requiring pairs to be distinct gives A068911, complement A365544.
The complement is counted by A366131.
(End) [Edited by Peter Munn, Nov 22 2023]

Examples

			The a(3)=6 palindromes of length 3 are: 101, 111, 121, 202, 212, and 222. - _M. F. Hasler_, May 05 2013
		

Crossrefs

Cf. A050683 and A070252.
Bisections are both A025192.
A093971/A088809/A364534 count certain types of sum-full subsets.
A108411 lists powers of 3 repeated, complement A167936.

Programs

  • Mathematica
    With[{c=NestList[3#&,2,20]},Riffle[c,c]] (* Harvey P. Dale, Mar 25 2018 *)
    Table[Length[Select[Subsets[Range[n]],!MemberQ[Total/@Tuples[#,2],n]&]],{n,0,10}] (* Gus Wiseman, Oct 18 2023 *)
  • PARI
    A117855(n)=2*3^((n-1)\2) \\ - M. F. Hasler, May 05 2013
    
  • Python
    def A117855(n): return 3**(n-1>>1)<<1 # Chai Wah Wu, Oct 28 2024

Formula

a(n) = 2*3^floor((n-1)/2).
a(n) = 2*A108411(n-1).
From Colin Barker, Feb 15 2013: (Start)
a(n) = 3*a(n-2).
G.f.: -2*x*(x+1)/(3*x^2-1). (End)

Extensions

More terms from Colin Barker, Feb 15 2013

A225367 Number of palindromes of length n in base 3 (A118594).

Original entry on oeis.org

3, 2, 6, 6, 18, 18, 54, 54, 162, 162, 486, 486, 1458, 1458, 4374, 4374, 13122, 13122, 39366, 39366, 118098, 118098, 354294, 354294, 1062882, 1062882, 3188646, 3188646, 9565938, 9565938, 28697814, 28697814, 86093442, 86093442, 258280326, 258280326, 774840978
Offset: 1

Views

Author

M. F. Hasler, May 05 2013

Keywords

Comments

Also: The number of n-digit terms in A006072. See there for further comments.
A palindrome of length L=2k-1 or of length L=2k is determined by the first k digits, which then determine the last k digits by symmetry. Since the first digit cannot be 0 (unless L=1), there are 2*3^(k-1) possibilities for L>1.
Except for the initial term, this is identical to A117855, which counts only nonzero palindromes.

Examples

			The a(1)=3 palindromes of length 1 are: 0, 1 and 2.
The a(2)=2 palindromes of length 2 are: 11 and 22.
		

Crossrefs

Cf. A050683 and A070252 for base 10 analogs.

Programs

  • Magma
    [n eq 1 select 3 else 2*3^Floor((n-1)/2): n in [1..40]]; // Bruno Berselli, May 06 2013
    
  • Magma
    I:=[3,2,6]; [n le 3 select I[n] else 3*Self(n-2): n in [1..40]]; // Vincenzo Librandi, May 31 2017
    
  • Mathematica
    Join[{3}, LinearRecurrence[{0, 3}, {2, 6}, 40]] (* Vincenzo Librandi, May 31 2017 *)
  • PARI
    A225367(n)=2*3^((n-1)\2)+!n
    
  • Python
    def A225367(n): return 3 if n==1 else 3**(n-1>>1)<<1 # Chai Wah Wu, Jul 30 2025

Formula

a(n) = 2*3^floor((n-1)/2) + [n=1].
a(n) = 3*a(n-2) for n>3.
G.f.: x*(3*x^2-2*x-3)/(3*x^2-1).
a(n) = (6-(1+(-1)^n)*(3-sqrt(3)))*sqrt(3)^(n-3) for n>1, a(1)=3. [Bruno Berselli, May 06 2013]

A050720 Number of nonzero palindromes of length n containing the digit '0'.

Original entry on oeis.org

0, 0, 9, 9, 171, 171, 2439, 2439, 30951, 30951, 368559, 368559, 4217031, 4217031, 46953279, 46953279, 512579511, 512579511, 5513215599, 5513215599, 58618940391, 58618940391, 617570463519, 617570463519, 6458134171671
Offset: 1

Views

Author

Patrick De Geest, Aug 15 1999

Keywords

Examples

			For length 3 we find nine numbers: 101, 202, ... 909, so a(3) = 9.
		

Crossrefs

Programs

  • Mathematica
    nzp[n_]:=Module[{k=Ceiling[n/2]},9*10^(k-1)-9^k]; Array[nzp,30] (* Harvey P. Dale, Jun 01 2019 *)

Formula

G.f.: 9*x^3*(x+1) / ((3*x-1)*(3*x+1)*(10*x^2-1)). - Colin Barker, Feb 15 2013
For n > 1, a(n) = 9*10^(k-1) - 9^k, where k = ceiling(n/2). - Jon E. Schoenfield, Sep 14 2013

Extensions

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

A218035 Number of n-digit palindromes with squares that are also palindromes.

Original entry on oeis.org

4, 2, 5, 3, 8, 5, 13, 9, 22, 16, 37, 27, 60, 43, 93, 65, 138, 94, 197, 131, 272, 177, 365, 233, 478, 300, 613, 379, 772, 471, 957, 577, 1170, 698, 1413, 835, 1688, 989, 1997, 1161, 2342, 1352, 2725, 1563, 3148, 1795, 3613, 2049, 4122, 2326, 4677, 2627, 5280, 2953
Offset: 1

Views

Author

David Zvirbulis, Oct 19 2012

Keywords

Comments

Number of n-digit terms in A057135.
From Chai Wah Wu, Apr 03 2021: (Start)
The conjectures in the formula section are true.
Theorem: a(n) = (n^3-6*n^2+32*n+48)/48 if n is even.
a(n) = (n^3-9*n^2+59*n-3)/24 if n > 1 is odd.
Proof: For n < 9, this is true by inspection.
The set of palindromes whose square are palindromic are the numbers whose squares of the digits sums to less than 10 (see A057135). For n >= 9, the nonzero digits are from one of the following 12 sets:
(1, 1, 1, 1, 1, 1, 1, 1), (1, 2, 2), (1, 1, 1, 1), (1, 1, 2), (1, 1, 1, 1, 1, 1, 1), (1, 1, 1, 1, 1, 1, 1, 1, 1), (2, 2), (1, 1, 1), (1, 1, 1, 1, 1), (1, 1), (1, 1, 1, 1, 2), (1, 1, 1, 1, 1, 1)
For odd n >= 9:
(1, 1, 1, 1, 1, 1, 1, 1): number of palindromes with 8 1's and n-8 0's is C((n-3)/2,3) = (n-3)(n-5)(n-7)/48. This is because all palindromes must start and end with a nonzero digit and the middle digit is necessarily 0, so only the (n-3) remaining digits are permuted with 6 1's and (n-9) 0's. By symmetry of the palindromes the number of combinations is C((n-3)/2,3).
(1, 2, 2): 1 palindrome of the form 20..010..2.
(1, 1, 1, 1): number of palindromes with 4 1's and n-4 0's is C((n-3)/2,1) = (n-3)/2.
(1, 1, 2): 1 palindrome of the form 10..020..1.
(1, 1, 1): 1 palindrome of the form 10..010..1.
(1, 1, 1, 1, 1): number of palindromes with 5 1's and n-5 0's is C((n-3)/2,1) = (n-3)/2.
(1, 1, 1, 1, 2): C((n-3)/2,1) = (n-3)/2.
(1, 1, 1, 1, 1, 1, 1): C((n-3)/2,2).
(1, 1, 1, 1, 1, 1, 1, 1, 1): C((n-3)/2,3).
(2,2): 1 palindrome of the form 200...002.
(1,1): 1 palindrome of the form 100...001.
(1,1,1,1,1,1): number of palindromes with 6 1's and n-6 0's is C((n-3)/2,2) = (n-3)(n-5)/8.
Thus A218035(n) = 2*(n-3)(n-5)(n-7)/48 +2*(n-3)(n-5)/8 +3*(n-3)/2 + 5 = (n^3-9n^2+59n-3)/24.
For even n >= 9:
(1, 2, 2), (1, 1, 2), (1, 1, 1), (1, 1, 1, 1, 1), (1, 1, 1, 1, 2), (1, 1, 1, 1, 1, 1, 1), (1, 1, 1, 1, 1, 1, 1, 1, 1): no palindromes are possible.
(1, 1, 1, 1, 1, 1, 1, 1): number of palindromes 8 1's and n-8 0's = C((n-2)/2,3) = (n-2)(n-4)(n-6)/48.
(1, 1, 1, 1): number of palindromes with 4 1's and n-4 0's is C((n-2)/2,1) = (n-2)/2.
(2,2): 1 palindrome of the form 200...002.
(1,1): 1 palindrome of the form 100...001.
(1,1,1,1,1,1): number of palindromes with 6 1's and n-6 0's is C((n-2)/2,2) = (n-2)(n-4)/8.
Thus A218035(n) = (n-2)(n-4)(n-6)/48 + (n-2)(n-4)/8 + (n-2)/2 +2 = (n^3-6n^2+32n+48)/48. QED
(End)

Examples

			For n=4, the solutions are:
1001, 1001^2 = 1002001,
1111, 1111^2 = 1234321,
2002, 2002^2 = 4008004.
		

Crossrefs

Programs

  • Python
    from itertools import product
    def ispal(n): s = str(n); return s == s[::-1]
    def pals(n):
      midrange = [[""], [str(i) for i in range(10)]]
      for p in product("0123456789", repeat=n//2):
        left = "".join(p)
        if len(left) and left[0] == '0': continue
        for middle in midrange[n%2]: yield left+middle+left[::-1]
    def a(n): return sum(ispal(int(strpal)**2) for strpal in pals(n))
    print([a(n) for n in range(1, 13)]) # Michael S. Branicky, Apr 02 2021
    
  • Python
    def A218035(n): return 4 if n == 1 else (n**3-9*n**2+59*n-3)//24 if n % 2 else (n**3-6*n**2+32*n+48)//48 # Chai Wah Wu, Apr 03 2021

Formula

Conjecture: a(n) = n^3/48 - n^2/8 + 2n/3 + 1 if n even, see A011826.
Conjecture: a(n) = n^3/24 - 3n^2/8 + 59n/24 - 1/8 if n odd, n > 1.
From Chai Wah Wu, Apr 03 2021: (Start)
a(n) = 4*a(n-2) - 6*a(n-4) + 4*a(n-6) - a(n-8) for n > 9.
G.f.: x*(2*x^8 - x^7 - 5*x^6 + 5*x^5 + 12*x^4 - 5*x^3 - 11*x^2 + 2*x + 4)/((x - 1)^4*(x + 1)^4). (End)

Extensions

a(19)-a(20) from Michael S. Branicky, Apr 02 2021
More terms from Chai Wah Wu, Apr 03 2021

A050686 Number of palindromes of length n and containing the digit 1 (or any other fixed nonzero digit).

Original entry on oeis.org

1, 1, 18, 18, 252, 252, 3168, 3168, 37512, 37512, 427608, 427608, 4748472, 4748472, 51736248, 51736248, 555626232, 555626232, 5900636088, 5900636088, 62105724792, 62105724792, 648951523128, 648951523128, 6740563708152
Offset: 1

Views

Author

Patrick De Geest, Aug 15 1999

Keywords

Examples

			For length 3 we find 18 numbers: 101, 111, 121, 131, 141, 151, 161, 171, 181, 191, 212, 313, 414, 515, 616, 717, 818, 919.
		

Crossrefs

Formula

Empirical g.f.: -x*(x-1)*(x+1)^2 / ((3*x-1)*(3*x+1)*(10*x^2-1)). - Colin Barker, Feb 15 2013
From Sela Fried, Dec 10 2024: (Start)
The conjectured g.f is correct.
a(n) = 9*10^(n/2 - 1) - 8*9^(n/2 - 1) if n is even
a(n) = 9*10^((n - 1)/2) - 8*9^((n - 1)/2) if n is odd. (End)

Extensions

More terms from Michael Lugo (mlugo(AT)thelabelguy.com), Dec 22 1999

A117856 Number of palindromes of length n (in base 4).

Original entry on oeis.org

3, 3, 12, 12, 48, 48, 192, 192, 768, 768, 3072, 3072, 12288, 12288, 49152, 49152, 196608, 196608, 786432, 786432, 3145728, 3145728, 12582912, 12582912, 50331648, 50331648, 201326592, 201326592, 805306368, 805306368, 3221225472, 3221225472, 12884901888
Offset: 1

Views

Author

Martin Renner, May 02 2006

Keywords

Crossrefs

Cf. A050683.

Programs

  • Mathematica
    NestList[4#&,{3,3},20]//Flatten (* Harvey P. Dale, Dec 19 2016 *)

Formula

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

Extensions

More terms from Colin Barker, Feb 15 2013

A117857 Number of palindromes of length n (in base 5).

Original entry on oeis.org

4, 4, 20, 20, 100, 100, 500, 500, 2500, 2500, 12500, 12500, 62500, 62500, 312500, 312500, 1562500, 1562500, 7812500, 7812500, 39062500, 39062500, 195312500, 195312500, 976562500, 976562500, 4882812500, 4882812500, 24414062500, 24414062500, 122070312500
Offset: 1

Views

Author

Martin Renner, May 02 2006

Keywords

Crossrefs

Cf. A050683.

Programs

  • Maple
    A117857:=n->4*5^floor((n-1)/2): seq(A117857(n), n=1..40); # Wesley Ivan Hurt, Apr 18 2017
  • Mathematica
    LinearRecurrence[{0,5},{4,4},40] (* or *) With[{c=NestList[ 5#&,4,20]},Riffle[ c,c]] (* Harvey P. Dale, Apr 18 2019 *)

Formula

a(n) = 4*5^floor((n-1)/2).
a(n) = 5*a(n-2). G.f.: -4*x*(x+1)/(5*x^2-1). [Colin Barker, Feb 15 2013]

Extensions

More terms from Colin Barker, Feb 15 2013

A117861 Number of palindromes of length n (in base 9).

Original entry on oeis.org

8, 8, 72, 72, 648, 648, 5832, 5832, 52488, 52488, 472392, 472392, 4251528, 4251528, 38263752, 38263752, 344373768, 344373768, 3099363912, 3099363912, 27894275208, 27894275208, 251048476872, 251048476872, 2259436291848, 2259436291848, 20334926626632
Offset: 1

Views

Author

Martin Renner, May 02 2006

Keywords

Crossrefs

Cf. A050683.
Cf. A055275.

Programs

  • Mathematica
    Table[8 9^Floor[(n-1)/2],{n,50}] (* Harvey P. Dale, Oct 21 2011 *)

Formula

a(n) = 8*9^floor((n-1)/2).
G.f.: 8*x*(1+x)/(1-9*x^2). a(n) = 8*3^(n-2)*(2-(-1)^n). - Bruno Berselli, Oct 24 2011

Extensions

More terms from Harvey P. Dale, Oct 21 2011
Showing 1-10 of 16 results. Next