login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

A206925
Number of contiguous palindromic bit patterns in the binary representation of n.
11
1, 2, 3, 4, 4, 4, 6, 7, 6, 6, 6, 6, 6, 7, 10, 11, 9, 8, 8, 8, 9, 8, 9, 9, 8, 8, 9, 9, 9, 11, 15, 16, 13, 11, 11, 11, 10, 10, 11, 11, 10, 12, 11, 10, 11, 11, 13, 13, 11, 10, 11, 10, 11, 11, 12, 12, 11, 11, 12, 13, 13, 16, 21, 22, 18, 15, 15, 14, 13, 13, 14, 14
OFFSET
1,2
COMMENTS
The number of contiguous palindromic bit patterns in the binary representation of n is a measure for the grade of symmetry in an abstract arrangement of two kinds of elements (where the number of elements is the number of binary digits, of course).
The minimum value for a(n) is 2*floor(log_2(n)) and will be taken infinitely often (see A206926 and A206927). This means: For a given number of places m there are at least 2*(m-1) palindromic substrings in the binary representation. This lower bound indicates to a certain extent the minimal possible symmetry.
FORMULA
a(n) <= (m+1)*(m+2)/2, where m = floor(log_2(n)); equality holds if n + 1 is a power of 2.
a(n) >= 2*floor(log_2(n)).
This estimation cannot be improved in general, since equality holds for A206926(n): a(A206926(n)) = 2*floor(log_2(A206926(n))).
Asymptotic behavior:
a(n) = O(log(n)^2).
lim sup a(n)/log_2(n)^2 = 1/2, for n --> infinity.
lim inf a(n)/log_2(n) = 2, for n --> infinity.
EXAMPLE
a(1) = 1, since 1 = 1_2 is the only palindromic bit pattern;
a(4) = 4, since 4 = 100_2 and there are the following palindromic bit patterns: 1, 0, 0, 00;
a(5) = 4, since 5 = 101_2 and there are the following palindromic bit patterns: 1, 0, 1, 101;
a(8) = 7, since 8 = 1000_2 and there are the following palindromic bit patterns: 1, 0, 0, 0, 00, 00, 000.
PROG
(PARI) a(n)=n=binary(n); sum(k=0, #n-1, sum(i=1, #n-k, prod(j=0, k\2, n[i+j]==n[i+k-j]))) \\ Charles R Greathouse IV, Mar 21 2012
(Haskell)
import Data.Map (fromList, (!), insert)
import Data.List (inits, tails)
a206925 n = a206925_list !! (n-1)
a206925_list = 1 : f [0, 1] (fromList [(Bin [0], 1), (Bin [1], 1)]) where
f bs'@(b:bs) m = y : f (succ bs') (insert (Bin bs') y m) where
y = m ! (Bin bs) +
length (filter (\ds -> ds == reverse ds) $ tail $ inits bs')
succ [] = [1]; succ (0:ds) = 1 : ds; succ (1:ds) = 0 : succ ds
-- Reinhard Zumkeller, Dec 17 2012
(Smalltalk)
"Answers the number of symmetric bit patterns of n as a binary."
| m p q n numSym |
n := self.
n < 2 ifTrue: [^1].
m := n integerFloorLog: 2.
p := n printStringRadix: 2.
numSym := 0.
1 to: m + 1
do:
[:k |
1 to: k
do:
[:j |
q := p copyFrom: j to: k.
q = q reverse ifTrue: [numSym := numSym + 1]]].
^numSym // Hieronymus Fischer, Feb 16 2013
(Python)
def A206925(n):
s = bin(n)[2:]
k = len(s)
return sum(1 for i in range(k) for j in range(i+1, k+1) if s[i:j] == s[j-1:i-1-k:-1]) # Chai Wah Wu, Jan 31 2023
KEYWORD
nonn,base
AUTHOR
Hieronymus Fischer, Mar 12 2012
EXTENSIONS
Comments and formulas added by Hieronymus Fischer, Jan 23 2013
STATUS
approved