login
This site is supported by donations to The OEIS Foundation.

 

Logo


Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A073785 Numbers in base -3. 10
0, 1, 2, 120, 121, 122, 110, 111, 112, 100, 101, 102, 220, 221, 222, 210, 211, 212, 200, 201, 202, 12020, 12021, 12022, 12010, 12011, 12012, 12000, 12001, 12002, 12120, 12121, 12122, 12110, 12111, 12112, 12100, 12101, 12102, 12220, 12221, 12222 (list; graph; refs; listen; history; text; internal format)
OFFSET

0,3

REFERENCES

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

LINKS

Reinhard Zumkeller, Table of n, a(n) for n = 0..10000

Jaime Rangel-Mondragon, Negabinary Numbers to Decimal

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, 3], {n, 0, 45}]

PROG

(Haskell)

a073785 0 = 0

a073785 n = a073785 n' * 10 + m where

   (n', m) = if r < 0 then (q + 1, r + 3) else (q, r)

             where (q, r) = quotRem n (negate 3)

-- Reinhard Zumkeller, Jul 07 2012

(Python)

def A073785(n):

    s, q = '', n

    while q >= 3 or q < 0:

        q, r = divmod(q, -3)

        if r < 0:

            q += 1

            r += 3

        s += str(r)

    return int(str(q)+s[::-1]) # Chai Wah Wu, Apr 09 2016

(PARI) A073785 = base(n, b=-3) = if(n, base(n\b, b)*10 + n%b, 0) \\ Jianing Song, Oct 20 2018

CROSSREFS

Cf. A007089.

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).

Cf. A320636 (negative numbers in base -3).

Sequence in context: A243512 A165163 A153658 * A102355 A206355 A157069

Adjacent sequences:  A073782 A073783 A073784 * A073786 A073787 A073788

KEYWORD

base,easy,nonn,changed

AUTHOR

Robert G. Wilson v, Aug 11 2002

STATUS

approved

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recent | More pages
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified October 23 18:36 EDT 2018. Contains 316529 sequences. (Running on oeis4.)