login
a(n) = Sum_{i=1..m} |d(i) - d(i-1)|, where Sum_{i=0..m} d(i)*2^i is the base-2 representation of n.
21

%I #29 Jul 13 2024 20:42:14

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

%T 2,3,4,3,2,3,4,5,4,3,4,3,2,1,2,3,2,3,4,3,2,1,2,3,2,1,2,1,0,1,2,3,2,3,

%U 4,3,2,3,4,5,4,3,4,3,2,3,4,5,4,5,6,5,4,3,4,5

%N a(n) = Sum_{i=1..m} |d(i) - d(i-1)|, where Sum_{i=0..m} d(i)*2^i is the base-2 representation of n.

%C Number of i such that |d(i) - d(i-1)| = 1, where Sum_{i=0..m} d(i)*2^i is the base-2 representation of n.

%H Reinhard Zumkeller, <a href="/A037834/b037834.txt">Table of n, a(n) for n = 1..10000</a>

%H Paul Barry, <a href="https://arxiv.org/abs/2107.00442">Conjectures and results on some generalized Rueppel sequences</a>, arXiv:2107.00442 [math.CO], 2021.

%H <a href="/index/Bi#binary">Index entries for sequences related to binary expansion of n</a>

%p A037834 := proc(n)

%p local dgs ;

%p dgs := convert(n,base,2);

%p add( abs(op(i,dgs)-op(i-1,dgs)),i=2..nops(dgs)) ;

%p end proc: # _R. J. Mathar_, Oct 16 2015

%t Table[Total@ Flatten@ Map[Abs@ Differences@ # &, Partition[ IntegerDigits[n, 2], 2, 1]], {n, 90}] (* _Michael De Vlieger_, May 09 2017 *)

%o (Haskell)

%o a037834 n = sum $ map fromEnum $ zipWith (/=) (tail bs) bs

%o where bs = a030308_row n

%o -- _Reinhard Zumkeller_, Feb 20 2014

%o (Python)

%o def A037834(n): return (n^(n>>1)).bit_count()-1 # _Chai Wah Wu_, Jul 13 2024

%Y A005811(n)-1.

%Y Cf. A030308.

%K nonn,base

%O 1,5

%A _Clark Kimberling_