OFFSET
1,1
LINKS
Eric Weisstein's World of Mathematics, Negadecimal
Eric Weisstein's World of Mathematics, Negabinary
Wikipedia, Negative base
EXAMPLE
-7 in base -3 is represented as 1202 (1*(-3)^3 + 2*(-3)^2 + 2 = -7), so a(7) = 1202;
-16 in base -3 is represented as 1102 (1*(-3)^3 + 1*(-3)^2 + 2 = -16), so a(16) = 1102;
-40 in base -3 is represented as 2222 (2*(-3)^3 + 2*(-3)^2 + 2*(-3) + 2 = -99), so a(40) = 2222.
PROG
(PARI) A073785 = base(n, b=-3) = if(n, base(n\b, b)*10 + n%b, 0)
a(n) = A073785(-n)
(Python)
def A073785(n): # after Reinhard Zumkeller
if n == 0: return 0
(q, r) = divmod(n, -3)
(nn, m) = (q, r) if r >= 0 else (q+1, r+3)
return A073785(nn)*10 + m
def a(n): return A073785(-n)
print([a(n) for n in range(1, 47)]) # Michael S. Branicky, Dec 11 2021
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Jianing Song, Oct 18 2018
STATUS
approved