cp's OEIS Frontend

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.

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

This page as a plain text file.
%I A156025 #16 Jul 24 2025 20:59:25
%S A156025 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 A156025 28,20,9,2,10,18,14,4,26,68,94,78,44,18,4,22,46,46,22,4,29,104,4,20,
%U A156025 36,28,8,52,140,202,168,80,20,2,14,40,60,50,22,4,152,23,2
%N A156025 Number of n-bit numbers whose binary representation's substrings represent the maximal number (A112509(n)) of distinct integers.
%C A156025 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 A156025 Martin Fuller, <a href="/A156025/b156025.txt">Table of n, a(n) for n = 1..80</a>
%H A156025 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 A156025 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 A156025 (Python)
%o A156025 from itertools import product
%o A156025 def c(w):
%o A156025     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 A156025 def a(n):
%o A156025     if n == 1: return 2
%o A156025     m, argm, cardm = -1, None, 0
%o A156025     for b in product("01", repeat=n-1):
%o A156025         v = c("1"+"".join(b))
%o A156025         if v == m: argm, cardm = int("1"+"".join(b), 2), cardm + 1
%o A156025         elif v > m: m, argm, cardm = v, int("1"+"".join(b), 2), 1
%o A156025     return cardm
%o A156025 print([a(n) for n in range(1, 21)]) # _Michael S. Branicky_, Jan 13 2023
%Y A156025 Cf. A078822, A112509 (corresponding maximum), A112510 (least such number), A112511 (greatest such number), A122953, A156022, A156023, A156024.
%K A156025 nonn,base
%O A156025 1,1
%A A156025 _Joseph Myers_, Feb 01 2009
%E A156025 a(32) onwards from _Martin Fuller_, Jul 24 2025