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.
%I A145799 #19 Sep 24 2017 02:30:50 %S A145799 1,1,3,1,5,3,7,1,9,5,5,3,5,7,15,1,17,9,9,5,21,5,7,3,9,5,27,7,7,15,31, %T A145799 1,33,17,17,9,9,9,9,5,9,21,21,5,45,7,15,3,17,9,51,5,21,27,27,7,9,7,27, %U A145799 15,15,31,63,1,65,33,33,17,17,17,17,9,73,9,9,9,9,9,15,5,17,9,9,21,85,21,21 %N A145799 a(n) = the largest integer that is an (odd) palindrome when represented in binary and that occurs in the binary representation of n. %C A145799 The binary expansion of a(n) is the largest (odd) palindrome that appears as a substring of the binary expansion of n. Nonzero binary palindromes are necessarily odd (see A006995). %C A145799 For n = 2^k, a(n) = 1 is the largest binary palindrome in the binary representation of n. %C A145799 a(2^k*A006995(n)) = A006995(n). - _Ray Chandler_, Oct 26 2008 %C A145799 a(m) = m iff m is a palindrome: a(A006995(n)) = A006995(n), a(A154809(n)) < A154809(n). - _Reinhard Zumkeller_, Sep 24 2015 %H A145799 Reinhard Zumkeller, <a href="/A145799/b145799.txt">Table of n, a(n) for n = 1..16384</a> %e A145799 20 in binary is 10100. The largest binary palindrome included in this binary representation is 101, which is 5 in decimal. So a(20) = 5. %t A145799 Block[{nn = 87, s}, s = Reverse@ Select[IntegerDigits[#, 2] & /@ Range[2^Log2@ nn], PalindromeQ]; Table[With[{d = IntegerDigits[n, 2]}, FromDigits[#, 2] &@ SelectFirst[s, SequenceCount[d, #] > 0 &]], {n, nn}]] (* _Michael De Vlieger_, Sep 23 2017 *) %o A145799 (Haskell) %o A145799 a145799 = maximum . map (foldr (\b v -> 2 * v + b) 0) . %o A145799 filter (\bs -> bs == reverse bs && head bs == 1) . %o A145799 substr . bin where %o A145799 substr [] = [] %o A145799 substr us'@(_:us) = sub us' ++ substr us where %o A145799 sub [] = []; sub (v:vs) = [v] : [v : ws | ws <- sub vs ] %o A145799 bin 0 = []; bin n = b : bin n' where (n', b) = divMod n 2 %o A145799 -- _Reinhard Zumkeller_, Sep 24 2015 %Y A145799 Cf. A006995, A145800. %Y A145799 Cf. A154809. %K A145799 base,nonn,look %O A145799 1,3 %A A145799 _Leroy Quet_, Oct 19 2008 %E A145799 Extended by _Ray Chandler_, Oct 26 2008