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

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

A307752 Number of n-digit palindromic pentagonal numbers.

Original entry on oeis.org

3, 1, 0, 2, 1, 1, 2, 2, 0, 4, 0, 0, 3, 1, 1, 1, 3, 2, 4, 1, 3, 1, 1, 0, 3, 3, 2, 2, 2, 0, 2, 0, 0, 1, 1, 1, 1, 1, 1, 1
Offset: 1

Views

Author

Robert Price, Apr 26 2019

Keywords

Comments

Number of n-digit terms in A002069.

Examples

			There are only two 4-digit pentagonal number that are palindromic, 1001 and 2882. Thus, a(4)=2.
		

Crossrefs

Programs

  • Mathematica
    A002069 = {0, 1, 5, 22, 1001, 2882, 15251, 720027, 7081807, 7451547, 26811862, 54177145, 1050660501, 1085885801, 1528888251, 2911771192, 2376574756732, 5792526252975, 5875432345785, 10810300301801, 264571020175462, 5292834004382925, 10808388588380801, 15017579397571051, 76318361016381367, 150621384483126051, 735960334433069537, 1003806742476083001, 1087959810189597801, 2716280733370826172};
    Table[Length[Select[A002069, IntegerLength[#] == n  || (n == 1 && # == 0) &]], {n, 18}] (* Robert Price, Apr 26 2019 *)
  • Python
    def afind(terms):
      m, n, c = 0, 1, 0
      while n <= terms:
        p = m*(3*m-1)//2
        s = str(p)
        if len(s) == n:
           if s == s[::-1]: c += 1
        else:
          print(c, end=", ")
          n, c = n+1, int(s == s[::-1])
        m += 1
    afind(14) # Michael S. Branicky, Mar 01 2021

Extensions

a(19)-a(22) from Michael S. Branicky, Mar 01 2021
a(23)-a(40) from Bert Dobbelaere, Apr 15 2025

A307766 Number of palindromic hexagonal numbers of length n whose index is also palindromic.

Original entry on oeis.org

3, 1, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
Offset: 1

Views

Author

Robert Price, Apr 27 2019

Keywords

Comments

Is there a nonzero term beyond a(7)?

Examples

			There is only one palindromic hexagonal number of length 4 whose index is also palindromic, 55->5995. Thus, a(4)=1.
		

Crossrefs

Programs

  • Mathematica
    A054969 = {0, 1, 6, 66, 3003, 5995, 15051, 66066, 617716, 828828, 1269621, 1680861, 5073705, 5676765, 1264114621, 5289009825, 6172882716, 13953435931, 1313207023131, 5250178710525, 6874200024786, 61728399382716, 602224464422206, 636188414881636, 1250444114440521, 16588189498188561, 58183932923938185, 66056806460865066, 67898244444289876, 514816979979618415, 3075488771778845703, 6364000440440004636, 15199896744769899151};
    A054970 = {0, 1, 2, 6, 39, 55, 87, 182, 556, 644, 797, 917, 1593, 1685, 25141, 51425, 55556, 83527, 810311, 1620213, 1853942, 5555556, 17352586, 17835196, 25004441, 91071921, 170563673, 181737182, 184252876, 507354403, 1240058219, 1783816196, 2756800387};
    Table[Length[ Select[A054970[[Table[ Select[Range[18], IntegerLength[A054969[[#]]] == n || (n == 1 && A054969[[#]] == 0) &], {n, 19}][[n]]]], PalindromeQ[#] &]], {n, 19}]

A307753 Number of palindromic pentagonal numbers of length n whose index is also palindromic.

Original entry on oeis.org

3, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
Offset: 1

Views

Author

Robert Price, Apr 26 2019

Keywords

Comments

Is there a nonzero term beyond a(5)?

Examples

			There is only one palindromic pentagonal number of length 4 whose index is also palindromic, 44->2882. Thus, a(4)=1.
		

Crossrefs

Programs

  • Mathematica
    A002069 = {0, 1, 5, 22, 1001, 2882, 15251, 720027, 7081807, 7451547, 26811862, 54177145, 1050660501, 1085885801, 1528888251, 2911771192, 2376574756732, 5792526252975, 5875432345785, 10810300301801, 264571020175462, 5292834004382925, 10808388588380801, 15017579397571051, 76318361016381367, 150621384483126051, 735960334433069537, 1003806742476083001, 1087959810189597801, 2716280733370826172};
    A028386 = {0, 1, 2, 4, 26, 44, 101, 693, 2173, 2229, 4228, 6010, 26466, 26906, 31926, 44059, 1258723, 1965117, 1979130, 2684561, 13280839, 59401650, 84885761, 100058581, 225563533, 316882086, 700457153, 818049201, 851649306, 1345679688};
    Table[Length[Select[A028386[[Table[Select[Range[18], IntegerLength[A002069[[#]]] == n  || (n == 1 && A002069[[#]] == 0) &], {n, 18}][[n]]]], PalindromeQ[#] &]], {n, 18}]

Extensions

a(19)-a(35) from Chai Wah Wu, Sep 07 2019
Showing 1-4 of 4 results.