|
|
A212529
|
|
Negative numbers in base -2.
|
|
10
|
|
|
11, 10, 1101, 1100, 1111, 1110, 1001, 1000, 1011, 1010, 110101, 110100, 110111, 110110, 110001, 110000, 110011, 110010, 111101, 111100, 111111, 111110, 111001, 111000, 111011, 111010, 100101, 100100, 100111, 100110, 100001, 100000, 100011, 100010, 101101, 101100, 101111, 101110, 101001, 101000, 101011, 101010, 11010101
(list;
graph;
refs;
listen;
history;
text;
internal format)
|
|
|
OFFSET
|
1,1
|
|
COMMENTS
|
The formula a(n) = A039724(-n) is slightly misleading because sequence A039724 isn't defined for n < 0, and none of the terms a(n) is a term of A039724. It can be seen as the definition of the extension of A039724 to negative indices. Also, recursive definitions or implementations of A039724 require that function to be defined for negative arguments, and using a generic formula it will work as expected for -n, n > 0. - M. F. Hasler, Oct 18 2018
|
|
LINKS
|
|
|
FORMULA
|
|
|
MAPLE
|
a:= proc(n) local d, i, l, m;
m:= n; l:= NULL;
for i from 0 while m>0 do
d:= irem(m, 2, 'm');
if d=1 and irem(i, 2)=0 then m:= m+1 fi;
l:= d, l
od; parse(cat(l))
end:
|
|
MATHEMATICA
|
negabin[n_] := negabin[n] = If[n == 0, 0, negabin[Quotient[n - 1, -2]]*10 + Mod[n, 2]]; a[n_] := negabin[-n]; Array[a, 50] (* Amiram Eldar, Jul 23 2023 *)
|
|
PROG
|
(Haskell)
(Python)
s, q = '', -n
while q >= 2 or q < 0:
q, r = divmod(q, -2)
if r < 0:
q += 1
r += 2
s += str(r)
|
|
CROSSREFS
|
Cf. A039724 (nonnegative numbers in base -2).
Cf. A007608 (nonnegative numbers in base -4), A212526 (negative numbers in base -4).
|
|
KEYWORD
|
nonn,base
|
|
AUTHOR
|
|
|
STATUS
|
approved
|
|
|
|