%I #25 Feb 06 2024 19:31:19
%S 0,1,-1,-2,2,3,5,4,-4,-3,-5,-6,-10,-9,-7,-8,8,9,7,6,10,11,13,12,20,21,
%T 19,18,14,15,17,16,-16,-15,-17,-18,-14,-13,-11,-12,-20,-19,-21,-22,
%U -26,-25,-23,-24,-40,-39,-41,-42,-38,-37,-35,-36,-28,-27,-29,-30
%N a(0) = 0 and for any n >= 0, a(n+1) is obtained by changing the rightmost possible digit in the negabinary representation of a(n) so as to get a value not yet in the sequence.
%C Binary Gray code, interpreted as negabinary number.
%C This sequence is a bijection from nonnegative integers to signed integers.
%C This sequence has similarities with A317018; in both sequences, the negabinary representations of consecutive terms differ exactly by one digit.
%H Rémy Sigrist, <a href="/A317050/b317050.txt">Table of n, a(n) for n = 0..16383</a>
%H Eric Weisstein's World of Mathematics, <a href="https://mathworld.wolfram.com/Negabinary.html">Negabinary</a>.
%H Wikipedia, <a href="https://en.wikipedia.org/wiki/Negative_base">Negative base</a>.
%F a(n) = A053985(A003188(n)).
%e The first terms, alongside their negabinary representation, are:
%e n a(n) nega(a(n))
%e -- ---- ----------
%e 0 0 0
%e 1 1 1
%e 2 -1 11
%e 3 -2 10
%e 4 2 110
%e 5 3 111
%e 6 5 101
%e 7 4 100
%e 8 -4 1100
%e 9 -3 1101
%e 10 -5 1111
%e 11 -6 1110
%e 12 -10 1010
%e 13 -9 1011
%e 14 -7 1001
%e 15 -8 1000
%e 16 8 11000
%e 17 9 11001
%e 18 7 11011
%e 19 6 11010
%e 20 10 11110
%e a(8) = -4 because nega(a(7)) = 100. Changing the rightmost digit gives 101 of which the decimal value in the sequence. Similarily, changing to 110 and 000 gives no new term. Changing to 1100 does so a(8) is the decimal value of 1100 which is -4. - _David A. Corneth_, Jul 22 2018
%o (PARI) a(n) = fromdigits(binary(bitxor(n, n>>1)), -2)
%Y Cf. A003188, A039724, A053985, A212529, A317018.
%K sign,look,base
%O 0,4
%A _Rémy Sigrist_, Jul 20 2018