This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.
%I A073785 #25 Feb 16 2025 08:32:46 %S A073785 0,1,2,120,121,122,110,111,112,100,101,102,220,221,222,210,211,212, %T A073785 200,201,202,12020,12021,12022,12010,12011,12012,12000,12001,12002, %U A073785 12120,12121,12122,12110,12111,12112,12100,12101,12102,12220,12221,12222 %N A073785 Numbers in base -3. %D A073785 D. E. Knuth, The Art of Computer Programming. Addison-Wesley, Reading, MA, 1969, Vol. 2, p. 189. %H A073785 Reinhard Zumkeller, <a href="/A073785/b073785.txt">Table of n, a(n) for n = 0..10000</a> %H A073785 Jaime Rangel-Mondragon, <a href="http://demonstrations.wolfram.com/NegabinaryNumbersToDecimal/">Negabinary Numbers to Decimal</a> %H A073785 Eric Weisstein's World of Mathematics, <a href="https://mathworld.wolfram.com/Negabinary.html">Negabinary</a> %H A073785 Wikipedia, <a href="http://en.wikipedia.org/wiki/Negative_base">Negative base</a> %t A073785 ToNegaBases[i_Integer, b_Integer] := FromDigits[ Rest[ Reverse[ Mod[ NestWhileList[(#1 - Mod[ #1, b])/-b &, i, #1 != 0 &], b]]]]; Table[ ToNegaBases[n, 3], {n, 0, 45}] %o A073785 (Haskell) %o A073785 a073785 0 = 0 %o A073785 a073785 n = a073785 n' * 10 + m where %o A073785 (n', m) = if r < 0 then (q + 1, r + 3) else (q, r) %o A073785 where (q, r) = quotRem n (negate 3) %o A073785 -- _Reinhard Zumkeller_, Jul 07 2012 %o A073785 (Python) %o A073785 def A073785(n): %o A073785 s, q = '', n %o A073785 while q >= 3 or q < 0: %o A073785 q, r = divmod(q, -3) %o A073785 if r < 0: %o A073785 q += 1 %o A073785 r += 3 %o A073785 s += str(r) %o A073785 return int(str(q)+s[::-1]) # _Chai Wah Wu_, Apr 09 2016 %o A073785 (PARI) A073785 = base(n, b=-3) = if(n, base(n\b, b)*10 + n%b, 0) \\ _Jianing Song_, Oct 20 2018 %Y A073785 Cf. A007089. %Y A073785 Nonnegative numbers in negative bases: A039723 (b=-10), A039724 (b=-2), this sequence (b=-3), A007608 (b=-4), A073786 (b=-5), A073787 (b=-6), A073788 (b=-7), A073789 (b=-8), A073790 (b=-9). %Y A073785 Cf. A320636 (negative numbers in base -3). %K A073785 base,easy,nonn %O A073785 0,3 %A A073785 _Robert G. Wilson v_, Aug 11 2002