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!)
A156025 Number of n-bit numbers whose binary representation's substrings represent the maximal number (A112509(n)) of distinct integers. 6

%I #10 Jan 13 2023 13:19:50

%S 2,1,1,3,2,6,5,1,4,5,2,8,10,4,16,22,12,2,10,19,17,7,1,5,9,7,2,11,24,

%T 28,20

%N Number of n-bit numbers whose binary representation's substrings represent the maximal number (A112509(n)) of distinct integers.

%C If only positive integer substrings are counted (see A156022), the first two terms become 1,2 (the n-bit numbers in question being 1, 10, 11 in binary) and all subsequent terms are unchanged.

%H 2008/9 British Mathematical Olympiad Round 2, <a href="http://www.bmoc.maths.org/home/bmo2-2009.pdf">Problem 4</a>, Jan 29 2009.

%e The n-bit numbers in question are, in binary, for n <= 8: 0 1; 10; 110; 1100 1101 1110, 11100 11101; 111000 111001 111010 111011 111100 111101; 1110100 1111000 1111001 1111010 1111011; 11110100.

%o (Python)

%o from itertools import product

%o def c(w):

%o return len(set(w[i:j+1] for i in range(len(w)) if w[i] != "0" for j in range(i,len(w)))) + int("0" in w)

%o def a(n):

%o if n == 1: return 2

%o m, argm, cardm = -1, None, 0

%o for b in product("01", repeat=n-1):

%o v = c("1"+"".join(b))

%o if v == m: argm, cardm = int("1"+"".join(b), 2), cardm + 1

%o elif v > m: m, argm, cardm = v, int("1"+"".join(b), 2), 1

%o return cardm

%o print([a(n) for n in range(1, 21)]) # _Michael S. Branicky_, Jan 13 2023

%Y Cf. A078822, A112509 (corresponding maximum), A112510 (least such number), A112511 (greatest such number), A122953, A156022, A156023, A156024.

%K nonn,base,more

%O 1,1

%A _Joseph Myers_, Feb 01 2009

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 24 03:08 EDT 2024. Contains 371918 sequences. (Running on oeis4.)