cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A281499 Write n in binary reflected Gray code, interchange the 1's and 0's, reverse the code and convert it back to decimal.

This page as a plain text file.
%I A281499 #9 May 22 2025 10:21:45
%S A281499 1,0,0,2,4,0,2,6,12,4,0,8,10,2,6,14,28,12,4,20,16,0,8,24,26,10,2,18,
%T A281499 22,6,14,30,60,28,12,44,36,4,20,52,48,16,0,32,40,8,24,56,58,26,10,42,
%U A281499 34,2,18,50,54,22,6,38,46,14,30,62,124,60,28,92,76,12,44,108,100,36,4,68,84,20,52,116,112,48,16,80,64,0,32,96,104,40,8,72,88,24,56,120
%N A281499 Write n in binary reflected Gray code, interchange the 1's and 0's, reverse the code and convert it back to decimal.
%H A281499 Indranil Ghosh, <a href="/A281499/b281499.txt">Table of n, a(n) for n = 0..10000</a>
%F A281499 a(n) = A036044(A003188(n)).
%e A281499 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.
%t A281499 Table[FromDigits[Reverse@ IntegerDigits[#, 2] &@ BitXor[n, Floor[n/2]] /. { 0 -> 1, 1 -> 0}, 2], {n, 0, 120}] (* _Michael De Vlieger_, Jan 23 2017 *)
%o A281499 (Python)
%o A281499 def G(n):
%o A281499     return bin(n^(n/2))[2:]
%o A281499 def a(n):
%o A281499     s=""
%o A281499     x=G(n)
%o A281499     for i in x:
%o A281499         if i=="1":s+="0"
%o A281499         else:s+="1"
%o A281499     s=s[::-1]
%o A281499     return int(s,2)
%Y A281499 Cf. A003188, A014550, A036044.
%K A281499 nonn,base
%O A281499 0,4
%A A281499 _Indranil Ghosh_, Jan 23 2017