login
Even positive integers in which, when written in binary, each run of 0's is of exactly the same length as the run of 1's immediately before it.
5

%I #28 Aug 28 2025 22:08:35

%S 2,10,12,42,44,50,56,170,172,178,184,202,204,226,240,682,684,690,696,

%T 714,716,738,752,810,812,818,824,906,908,962,992,2730,2732,2738,2744,

%U 2762,2764,2786,2800,2858,2860,2866,2872,2954,2956,3010,3040,3242,3244,3250,3256

%N Even positive integers in which, when written in binary, each run of 0's is of exactly the same length as the run of 1's immediately before it.

%C Each term, when written in binary, contains an even number of digits, obviously.

%C The runs of 0's in the n-th term form the composition in the n-th row of A228369. - _John Tyler Rascoe_, Sep 05 2024

%H John Tyler Rascoe, <a href="/A166751/b166751.txt">Table of n, a(n) for n = 1..8192</a>

%e The first 7 terms written in binary: 10, 1010, 1100, 101010, 101100, 110010, 111000.

%e From _Paolo Xausa_, Aug 28 2025: (Start)

%e Terms can be arranged in an irregular triangle, where row n >= 1 has length 2^(n-1), row sum A386705(n), and lists all the terms with bit length 2*n:

%e 2;

%e 10, 12;

%e 42, 44, 50, 56;

%e 170, 172, 178, 184, 202, 204, 226, 240;

%e 682, 684, 690, 696, 714, 716, 738, 752, 810, 812, 818, 824, 906, 908, 962, 992;

%e ... (End)

%t A166751row[n_] := With[{b = Array[IntegerDigits[4^# - 2^#, 2] &, n]}, Sort[Flatten[Map[FromDigits[Flatten[#], 2] &, Map[b[[#]] &, Map[Permutations, IntegerPartitions[n]], {2}], {2}]]]]; (* Generates terms with bit length = 2*n *)

%t Array[A166751row, 6] (* _Paolo Xausa_, Aug 28 2025 *)

%o (Python)

%o from itertools import groupby

%o def ok(n):

%o L = [len(list(g)) for k, g in groupby(bin(n)[2:])]

%o return (m:=len(L))&1 == 0 and all(L[2*j] == L[2*j+1] for j in range(m>>1))

%o print([k for k in range(10**4) if ok(k)]) # _Michael S. Branicky_, Aug 25 2025

%Y Cf. A066099, A164707, A175413, A228369, A386705.

%K base,nonn

%O 1,1

%A _Leroy Quet_, Oct 21 2009

%E Extended by _Ray Chandler_, Mar 11 2010