A052059 Least k such that the longest palindromic substring (without leading zeros) contained in 2^k has length n.
0, 16, 17, 47, 49, 41, 146, 274, 76, 468, 1622, 4381, 2961, 12799, 4292, 28493, 34597, 16276
Offset: 1
Examples
a(3) = 17 since 2^17 = {131}072.
Programs
-
Python
def ispal(s): return s == s[::-1] def longestpalss(n): s = str(n) for l in range(len(s), 0, -1): for offset in range(len(s)-l+1): if s[offset] != '0' and ispal(s[offset:offset+l]): return l def a(n): k, pow2 = 0, 1 while longestpalss(pow2) != n: k += 1; pow2 <<= 1 return k print([a(n) for n in range(1, 11)]) # Michael S. Branicky, Nov 12 2021
Extensions
a(11)=1445 from Erich Friedman, Feb 19 2000
Title clarified, a(11) corrected, and a(12)-a(15) from Sean A. Irvine, Oct 19 2021
a(16)-a(18) from Michael S. Branicky, Nov 12 2021
Comments