login
Write n in the Elias gamma code and sum the positions where there is a '1' followed immediately to the right by a '0', counting the leftmost digit as position 1.
1

%I #7 Jan 27 2017 13:14:59

%S 0,1,1,2,2,6,2,3,3,9,3,8,8,9,3,4,4,12,4,11,11,12,4,10,10,18,10,11,11,

%T 12,4,5,5,15,5,14,14,15,5,13,13,23,13,14,14,15,5,12,12,22,12,21,21,22,

%U 12,13,13,23,13,14,14,15,5,6,6,18,6,17,17,18,6,16,16,28,16,17,17,18,6

%N Write n in the Elias gamma code and sum the positions where there is a '1' followed immediately to the right by a '0', counting the leftmost digit as position 1.

%H Indranil Ghosh, <a href="/A281552/b281552.txt">Table of n, a(n) for n = 1..10000</a>

%F a(n) = A049501(A171885(n)) for n > = 1.

%e For n = 6 , the Elias gamma code for n is '11010'. In '11010', the positions of '1' followed immediately to the right by '0' counting from left are 2 and 4. So, a(6) = 2 + 4 = 6.

%e For n = 10, the Elias gamma code for n is '1110010'. In '1110010', the positions of '1' followed immediately to the right by '0' counting from left are 3 and 6. So, a(10) = 3 + 6 = 9.

%o (Python)

%o def a(n):

%o ....x= A281149(n)

%o ....s=0

%o ....for i in range(1,len(x)):

%o ........if x[i-1]=="1" and x[i]=="0":

%o ............s+=i

%o ....return s

%Y Cf. A049501, A171885, A281149, A281388, A281497.

%K nonn,base

%O 1,4

%A _Indranil Ghosh_, Jan 24 2017