A166751 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.
2, 10, 12, 42, 44, 50, 56, 170, 172, 178, 184, 202, 204, 226, 240, 682, 684, 690, 696, 714, 716, 738, 752, 810, 812, 818, 824, 906, 908, 962, 992, 2730, 2732, 2738, 2744, 2762, 2764, 2786, 2800, 2858, 2860, 2866, 2872, 2954, 2956, 3010, 3040, 3242, 3244, 3250, 3256
Offset: 1
Examples
The first 7 terms written in binary: 10, 1010, 1100, 101010, 101100, 110010, 111000. From _Paolo Xausa_, Aug 28 2025: (Start) 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: 2; 10, 12; 42, 44, 50, 56; 170, 172, 178, 184, 202, 204, 226, 240; 682, 684, 690, 696, 714, 716, 738, 752, 810, 812, 818, 824, 906, 908, 962, 992; ... (End)
Links
- John Tyler Rascoe, Table of n, a(n) for n = 1..8192
Programs
-
Mathematica
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 *) Array[A166751row, 6] (* Paolo Xausa, Aug 28 2025 *)
-
Python
from itertools import groupby def ok(n): L = [len(list(g)) for k, g in groupby(bin(n)[2:])] return (m:=len(L))&1 == 0 and all(L[2*j] == L[2*j+1] for j in range(m>>1)) print([k for k in range(10**4) if ok(k)]) # Michael S. Branicky, Aug 25 2025
Extensions
Extended by Ray Chandler, Mar 11 2010
Comments