login
Number of runs of 1's of length 1 in the binary expansion of n.
1

%I #8 Oct 01 2024 23:18:39

%S 0,1,1,0,1,2,0,0,1,2,2,1,0,1,0,0,1,2,2,1,2,3,1,1,0,1,1,0,0,1,0,0,1,2,

%T 2,1,2,3,1,1,2,3,3,2,1,2,1,1,0,1,1,0,1,2,0,0,0,1,1,0,0,1,0,0,1,2,2,1,

%U 2,3,1,1,2,3,3,2,1,2,1,1,2,3,3,2,3,4,2

%N Number of runs of 1's of length 1 in the binary expansion of n.

%C 2^a(n) is the run length transform of 1,2,1,1,1,1,....

%H Chai Wah Wu, <a href="/A277937/b277937.txt">Table of n, a(n) for n = 0..10000</a>

%F a(2n) = a(n), a(4n+1) = a(8n+1) = a(n) + 1, a(8n+3) = a(n), a(8n+5) = a(2n+1) + 1, a(8n+7) = a(4n+3).

%e a(25) = 1 since 25 = 11001_2 has one runs of 1's of length 1.

%t A292342[n_] := Count[Split[IntegerDigits[n, 2]], {1}];

%t Array[A292342, 100, 0] (* _Paolo Xausa_, Oct 01 2024 *)

%o (Python)

%o def A277937(n):

%o return sum(1 for d in bin(n)[2:].split('0') if len(d) == 1)

%K nonn

%O 0,6

%A _Chai Wah Wu_, Mar 24 2017