OFFSET
0,4
LINKS
Indranil Ghosh, Table of n, a(n) for n = 0..10000
EXAMPLE
For n = 11, the binary reflected Gray code for 11 is '1110' which after interchanging the 1's and 0's becomes '0001', which on reversing further gives '1000'. Now, 1000_2 = 8_10. So, a(11) = 8.
MATHEMATICA
Table[FromDigits[Reverse@ IntegerDigits[#, 2] &@ BitXor[n, Floor[n/2]] /. { 0 -> 1, 1 -> 0}, 2], {n, 0, 120}] (* Michael De Vlieger, Jan 23 2017 *)
PROG
(Python)
def G(n):
....return bin(n^(n/2))[2:]
def a(n):
....s=""
....x=G(n)
....for i in x:
........if i=="1":s+="0"
........else:s+="1"
....s=s[::-1]
....return int(s, 2)
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Indranil Ghosh, Jan 23 2017
STATUS
approved