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

%I #12 Jan 13 2023 16:27:26

%S 1,2,6,14,29,61,123,244,500,1004,2009,4057,8121,16243,32627,65267,

%T 130535,261066,523210,1046474,2092954,4185909,8371816,16760424,

%U 33521256,67042536,134085073,268302801,536607185,1073214417,2146428840

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

%C See A112509 for a full explanation and example.

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

%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 m, argm = -1, None

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

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

%o if v >= m:

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

%o return argm

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

%Y Cf. A112509 (corresponding maximum), A112510 (least n-bit number for which this maximum occurs).

%Y A078822, A122953, A156022, A156023, A156024, A156025. [From _Joseph Myers_, Feb 01 2009]

%K base,nonn

%O 1,2

%A _Rick L. Shepherd_, Sep 09 2005

%E a(21)-a(31) from _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 May 6 07:22 EDT 2024. Contains 372290 sequences. (Running on oeis4.)