login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A206925 Number of contiguous palindromic bit patterns in the binary representation of n. 11

%I #42 Jan 31 2023 11:53:25

%S 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,

%T 13,11,11,11,10,10,11,11,10,12,11,10,11,11,13,13,11,10,11,10,11,11,12,

%U 12,11,11,12,13,13,16,21,22,18,15,15,14,13,13,14,14

%N Number of contiguous palindromic bit patterns in the binary representation of n.

%C 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).

%C 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.

%H Reinhard Zumkeller, <a href="/A206925/b206925.txt">Table of n, a(n) for n = 1..10000</a>

%H <a href="/index/Bi#binary">Index entries for sequences related to binary expansion of n</a>

%H <a href="/index/Pac#palindromes">Index entries for sequences related to palindromes</a>

%F a(n) <= (m+1)*(m+2)/2, where m = floor(log_2(n)); equality holds if n + 1 is a power of 2.

%F a(n) >= 2*floor(log_2(n)).

%F This estimation cannot be improved in general, since equality holds for A206926(n): a(A206926(n)) = 2*floor(log_2(A206926(n))).

%F Asymptotic behavior:

%F a(n) = O(log(n)^2).

%F lim sup a(n)/log_2(n)^2 = 1/2, for n --> infinity.

%F lim inf a(n)/log_2(n) = 2, for n --> infinity.

%e a(1) = 1, since 1 = 1_2 is the only palindromic bit pattern;

%e a(4) = 4, since 4 = 100_2 and there are the following palindromic bit patterns: 1, 0, 0, 00;

%e a(5) = 4, since 5 = 101_2 and there are the following palindromic bit patterns: 1, 0, 1, 101;

%e a(8) = 7, since 8 = 1000_2 and there are the following palindromic bit patterns: 1, 0, 0, 0, 00, 00, 000.

%o (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

%o (Haskell)

%o import Data.Map (fromList, (!), insert)

%o import Data.List (inits, tails)

%o a206925 n = a206925_list !! (n-1)

%o a206925_list = 1 : f [0, 1] (fromList [(Bin [0], 1), (Bin [1], 1)]) where

%o f bs'@(b:bs) m = y : f (succ bs') (insert (Bin bs') y m) where

%o y = m ! (Bin bs) +

%o length (filter (\ds -> ds == reverse ds) $ tail $ inits bs')

%o succ [] = [1]; succ (0:ds) = 1 : ds; succ (1:ds) = 0 : succ ds

%o -- _Reinhard Zumkeller_, Dec 17 2012

%o (Smalltalk)

%o A206925

%o "Answers the number of symmetric bit patterns of n as a binary."

%o | m p q n numSym |

%o n := self.

%o n < 2 ifTrue: [^1].

%o m := n integerFloorLog: 2.

%o p := n printStringRadix: 2.

%o numSym := 0.

%o 1 to: m + 1

%o do:

%o [:k |

%o 1 to: k

%o do:

%o [:j |

%o q := p copyFrom: j to: k.

%o q = q reverse ifTrue: [numSym := numSym + 1]]].

%o ^numSym // _Hieronymus Fischer_, Feb 16 2013

%o (Python)

%o def A206925(n):

%o s = bin(n)[2:]

%o k = len(s)

%o 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

%Y Cf. A006995, A206923, A206924, A206925, A206926, A070939.

%Y Cf. A215244, A030308.

%K nonn,base

%O 1,2

%A _Hieronymus Fischer_, Mar 12 2012

%E Comments and formulas added by _Hieronymus Fischer_, Jan 23 2013

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified April 16 07:57 EDT 2024. Contains 371698 sequences. (Running on oeis4.)