login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A212526 Negative integers in base -4. 8

%I #26 Apr 10 2016 02:31:14

%S 13,12,11,10,23,22,21,20,33,32,31,30,1303,1302,1301,1300,1313,1312,

%T 1311,1310,1323,1322,1321,1320,1333,1332,1331,1330,1203,1202,1201,

%U 1200,1213,1212,1211,1210,1223,1222,1221,1220

%N Negative integers in base -4.

%C Interleaving with zeros gives A212542 (base 2i representation of negative integers).

%C More precisely, a(n) is the representation of -n in base -4. - _M. F. Hasler_, May 21 2012

%H Joerg Arndt, <a href="/A212526/b212526.txt">Table of n, a(n) for n = 1..1000</a>

%e a(13)=1303: 1*(-4)^3 + 3*(-4)^2 + 0*(-4)^1 + 3*(-4)^0 = -64 + 48 +3 = -13.

%p a:= proc(n) local d, i, l, m;

%p m:= n;

%p l:= NULL;

%p for i from 0 while m>0 do

%p d:= irem(m, 4, 'm');

%p if irem (i, 2)=0 and d>0 then d:= 4-d; m:= m+1 fi;

%p l:= d, l

%p od; parse(cat(l))

%p end:

%p seq(a(n), n=1..60); # _Alois P. Heinz_, May 20 2012

%o (PARI) A212526(n,s="")={n=-n;until(!n\=-4,s=Str(n%-4,s));eval(s)} \\ _M. F. Hasler_, May 21 2012

%o (Python)

%o def A212526(n):

%o s, q = '', -n

%o while q >= 4 or q < 0:

%o q, r = divmod(q, -4)

%o if r < 0:

%o q += 1

%o r += 4

%o s += str(r)

%o return int(str(q)+s[::-1]) # _Chai Wah Wu_, Apr 10 2016

%Y Cf. A007608 (Nonnegative integers in base -4).

%K nonn,base

%O 1,1

%A _Joerg Arndt_, May 20 2012

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified April 19 21:09 EDT 2024. Contains 371798 sequences. (Running on oeis4.)