|
|
A007608
|
|
Nonnegative integers in base -4.
(Formerly M0926)
|
|
19
|
|
|
0, 1, 2, 3, 130, 131, 132, 133, 120, 121, 122, 123, 110, 111, 112, 113, 100, 101, 102, 103, 230, 231, 232, 233, 220, 221, 222, 223, 210, 211, 212, 213, 200, 201, 202, 203, 330, 331, 332, 333, 320, 321, 322, 323, 310, 311, 312, 313, 300, 301, 302, 303, 13030
(list;
graph;
refs;
listen;
history;
text;
internal format)
|
|
|
OFFSET
|
0,3
|
|
COMMENTS
|
The base 2i representation (quater-imaginary representation) of nonnegative integers is obtained by interleaving with zeros, cf. A212494.
More precisely, a(n) is the number n written in base -4; numbers [which represent some nonnegative integer] in base -4 are 0, 1, 2, 3, 100, 101, 102, 103, 110, 111, 112, 113, 120, 121, 122, 123, 130, 131, 132, 133, ... (A212556) - M. F. Hasler, May 20 2012
|
|
REFERENCES
|
D. E. Knuth, The Art of Computer Programming. Addison-Wesley, Reading, MA, 1969, Vol. 2, p. 189.
N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).
|
|
LINKS
|
Joerg Arndt, Table of n, a(n) for n = 0..1000
Matthew Szudzik, A Mathematica programming contest
Eric Weisstein's World of Mathematics, Negabinary
Wikipedia, Negative base
|
|
MATHEMATICA
|
ToNegaBases[i_Integer, b_Integer] := FromDigits[ Rest[ Reverse[ Mod[ NestWhileList[(#1 - Mod[ #1, b])/-b &, i, #1 != 0 &], b]]]]; Table[ ToNegaBases[n, 4], {n, 0, 55}]
|
|
PROG
|
(PARI) A007608(n, s="")={until(!n\=-4, s=Str(n%-4, s)); eval(s)} \\ M. F. Hasler, May 20 2012
(Haskell)
a007608 0 = 0
a007608 n = a007608 n' * 10 + m where
(n', m) = if r < 0 then (q + 1, r + 4) else (q, r)
where (q, r) = quotRem n (negate 4)
-- Reinhard Zumkeller, Jul 15 2012
(Python)
def A007608(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 09 2016
|
|
CROSSREFS
|
Cf. A212556 (sorted), A066323 (sum of digits), A212526 (negative integers in base -4).
Other bases: A007090, A039724, A073785, A073786, A073787, A073788, A073789, A073790 & A039723.
Sequence in context: A004865 A006286 A139129 * A010343 A118169 A066908
Adjacent sequences: A007605 A007606 A007607 * A007609 A007610 A007611
|
|
KEYWORD
|
base,nice,easy,nonn
|
|
AUTHOR
|
N. J. A. Sloane, Robert G. Wilson v, Mira Bernstein
|
|
STATUS
|
approved
|
|
|
|