OFFSET
1,4
LINKS
Indranil Ghosh, Table of n, a(n) for n = 1..10000
EXAMPLE
For n = 11, the binary reflected Gray code for 11 is '1110'. In '1110', the position of '1' followed immediately to the right by '0' counting from left is 3. So, a(11) = 3.
For n = 12, the binary reflected Gray code for 12 is '1010'. In '1010', the positions of '1' followed immediately to the right by '0' counting from left are 1 and 3. So, a(12) = 1 + 3 = 4.
PROG
(Python)
def g(n):
....return bin(n^(n/2))[2:]
def a(n):
....x=g(n)
....s=0
....for i in range(1, len(x)):
........if x[i-1]=="1" and x[i]=="0":
............s+=i
....return s
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Indranil Ghosh, Jan 21 2017
STATUS
approved