login
Those positive integers n that when written in binary, each run of 0's and 1's has a length which divides the number of binary digits of n.
2

%I #18 Nov 08 2022 01:41:22

%S 1,2,3,5,7,9,10,11,12,13,15,21,31,34,35,36,37,38,39,40,41,42,43,44,45,

%T 46,49,50,51,52,53,54,55,56,57,58,59,63,85,127,132,133,134,144,146,

%U 147,148,149,150,153,154,155,158,161,164,165,166,169,170,171,172

%N Those positive integers n that when written in binary, each run of 0's and 1's has a length which divides the number of binary digits of n.

%H Paul Tek, <a href="/A175415/b175415.txt">Table of n, a(n) for n = 1..10000</a>

%e 35 in binary is 100011. There is a run of one 1, followed by a run of three 0's, followed finally by a run of two 1's. And there are six binary digits all together. Since 1, 3, and 2 each divide 6, then 35 is in the sequence.

%o (Python)

%o from itertools import groupby

%o def ok(n):

%o b = bin(n)[2:]

%o return all(len(b)%len(list(g)) == 0 for k, g in groupby(b))

%o print([k for k in range(1, 173) if ok(k)]) # _Michael S. Branicky_, Nov 07 2022

%Y Cf. A175416

%K base,nonn

%O 1,2

%A _Leroy Quet_, May 07 2010