login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

A212526
Negative integers in base -4.
8
13, 12, 11, 10, 23, 22, 21, 20, 33, 32, 31, 30, 1303, 1302, 1301, 1300, 1313, 1312, 1311, 1310, 1323, 1322, 1321, 1320, 1333, 1332, 1331, 1330, 1203, 1202, 1201, 1200, 1213, 1212, 1211, 1210, 1223, 1222, 1221, 1220
OFFSET
1,1
COMMENTS
Interleaving with zeros gives A212542 (base 2i representation of negative integers).
More precisely, a(n) is the representation of -n in base -4. - M. F. Hasler, May 21 2012
EXAMPLE
a(13)=1303: 1*(-4)^3 + 3*(-4)^2 + 0*(-4)^1 + 3*(-4)^0 = -64 + 48 +3 = -13.
MAPLE
a:= proc(n) local d, i, l, m;
m:= n;
l:= NULL;
for i from 0 while m>0 do
d:= irem(m, 4, 'm');
if irem (i, 2)=0 and d>0 then d:= 4-d; m:= m+1 fi;
l:= d, l
od; parse(cat(l))
end:
seq(a(n), n=1..60); # Alois P. Heinz, May 20 2012
PROG
(PARI) A212526(n, s="")={n=-n; until(!n\=-4, s=Str(n%-4, s)); eval(s)} \\ M. F. Hasler, May 21 2012
(Python)
def A212526(n):
s, q = '', -n
while q >= 4 or q < 0:
q, r = divmod(q, -4)
if r < 0:
q += 1
r += 4
s += str(r)
return int(str(q)+s[::-1]) # Chai Wah Wu, Apr 10 2016
CROSSREFS
Cf. A007608 (Nonnegative integers in base -4).
Sequence in context: A022969 A023455 A055124 * A019331 A004454 A113548
KEYWORD
nonn,base
AUTHOR
Joerg Arndt, May 20 2012
STATUS
approved