cp's OEIS Frontend

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.

A039723 Numbers in base -10.

Original entry on oeis.org

0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 150, 151, 152, 153, 154, 155
Offset: 0

Views

Author

Robert Lozyniak (11(AT)onna.com)

Keywords

Examples

			Decimal 25 is "185" in base -10 because 100 - 80 + 5 = 25.
		

References

  • D. E. Knuth, The Art of Computer Programming. Addison-Wesley, Reading, MA, 1969, Vol. 2, p. 189.

Crossrefs

Nonnegative numbers in negative bases: this sequence (b=-10), A039724 (b=-2), A073785 (b=-3), A007608 (b=-4), A073786 (b=-5), A073787 (b=-6), A073788 (b=-7), A073789 (b=-8), A073790 (b=-9).
Cf. A051022.
Cf. A305238: negative numbers in base -10.

Programs

  • Haskell
    a039723 0 = 0
    a039723 n = a039723 n' * 10 + m where
       (n',m) = if r < 0 then (q + 1, r + 10) else qr where
                qr@(q, r) = quotRem n (negate 10)
    -- Reinhard Zumkeller, Apr 20 2011
    
  • Mathematica
    ToNegaBases[i_Integer, b_Integer] := FromDigits@ Rest@ Reverse@ Mod[ NestWhileList[(# - Mod[ #, b])/-b &, i, # != 0 &], b]
  • PARI
    A039723 = base(n, b=-10) = if(n, base(n\b, b)*10 + n%b, 0) \\ M. F. Hasler, Oct 16 2018 [Corrected by Jianing Song, Oct 21 2018]
  • Python
    def A039723(n):
        s, q = '', n
        while q >= 10 or q < 0:
            q, r = divmod(q, -10)
            if r < 0:
                q += 1
                r += 10
            s += str(r)
        return int(str(q)+s[::-1]) # Chai Wah Wu, Apr 10 2016