OFFSET
0,4
COMMENTS
Binary Gray code, interpreted as negabinary number.
This sequence is a bijection from nonnegative integers to signed integers.
This sequence has similarities with A317018; in both sequences, the negabinary representations of consecutive terms differ exactly by one digit.
LINKS
Rémy Sigrist, Table of n, a(n) for n = 0..16383
Eric Weisstein's World of Mathematics, Negabinary.
Wikipedia, Negative base.
EXAMPLE
The first terms, alongside their negabinary representation, are:
n a(n) nega(a(n))
-- ---- ----------
0 0 0
1 1 1
2 -1 11
3 -2 10
4 2 110
5 3 111
6 5 101
7 4 100
8 -4 1100
9 -3 1101
10 -5 1111
11 -6 1110
12 -10 1010
13 -9 1011
14 -7 1001
15 -8 1000
16 8 11000
17 9 11001
18 7 11011
19 6 11010
20 10 11110
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
PROG
(PARI) a(n) = fromdigits(binary(bitxor(n, n>>1)), -2)
CROSSREFS
KEYWORD
AUTHOR
Rémy Sigrist, Jul 20 2018
STATUS
approved