OFFSET
0,3
REFERENCES
D. E. Knuth, The Art of Computer Programming. Addison-Wesley, Reading, MA, 1969, Vol. 2, p. 189.
LINKS
Chai Wah Wu, Table of n, a(n) for n = 0..10000
Eric Weisstein's World of Mathematics, Negabinary
Prepared and presented by Matthew Szudzik of Wolfram Research, A Mathematica programming contest
MATHEMATICA
ToNegaBases[i_Integer, b_Integer] := FromDigits@ Rest@ Reverse@ Mod[ NestWhileList[(# - Mod[ #, b])/-b &, i, # != 0 &], b]; Table[ ToNegaBases[n, 9], {n, 0, 60}]
PROG
(Python)
def A073790(n):
s, q = '', n
while q >= 9 or q < 0:
q, r = divmod(q, -9)
if r < 0:
q += 1
r += 9
s += str(r)
return int(str(q)+s[::-1]) # Chai Wah Wu, Apr 09 2016
CROSSREFS
KEYWORD
base,easy,nonn
AUTHOR
Robert G. Wilson v, Aug 11 2002
STATUS
approved