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

 

Logo

Annual appeal: Please make a donation to keep the OEIS running! Over 6000 articles have referenced us, often saying "we discovered this result with the help of the OEIS".
Other ways to donate

Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A005351 Base -2 representation for n regarded as base 2, then evaluated.
(Formerly M4059)
13
0, 1, 6, 7, 4, 5, 26, 27, 24, 25, 30, 31, 28, 29, 18, 19, 16, 17, 22, 23, 20, 21, 106, 107, 104, 105, 110, 111, 108, 109, 98, 99, 96, 97, 102, 103, 100, 101, 122, 123, 120, 121, 126, 127, 124, 125, 114, 115, 112, 113, 118, 119, 116, 117, 74, 75, 72, 73, 78, 79, 76 (list; graph; refs; listen; history; text; internal format)
OFFSET

0,3

COMMENTS

a(n) = n when n is a power of 4. This is because the even-indexed powers of 2 are the same as the even-indexed powers of -2. - Alonso del Arte, Feb 09 2012

a(n) = n if n is a sum of distinct powers of 4. - Michael Somos, Aug 27 2012

REFERENCES

M. Gardner, Knotted Doughnuts and Other Mathematical Entertainments. Freeman, NY, 1986, p. 101.

N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).

LINKS

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

Joerg Arndt, Matters Computational (The Fxtbook), p. 58-59

Eric Weisstein's World of Mathematics, Negabinary

Wikipedia, Negative base

A. Wilks, Email, May 22 1991

FORMULA

a(4n+2) = 4a(n+1)+2, a(4n+3) = 4a(n+1)+3, a(4n+4) = 4a(n+1), a(4n+5) = 4a(n+1)+1, n>-2, a(1)=1. - Ralf Stephan, Apr 06 2004

EXAMPLE

2 = 4+(-2)+0 = 110 => 6, 3 = 4+(-2)+1 = 111 => 7, ..., 6 = (16)+(-8)+0+(-2)+0 = 11010 => 26.

MATHEMATICA

f[n_] := Module[{t = 2(4^Floor[ Log[4, Abs[n] + 1] + 2] - 1)/3}, BitXor[n + t, t]]; Table[ f[n]], {n, 0, 60}] (* Robert G. Wilson v, Jan 24 2005 *)

PROG

(Haskell)

a005351 0 = 0

a005351 n = a005351 n' * 2 + m where

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

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

-- Reinhard Zumkeller, Jul 07 2012

(Python)

def A005351(n):

    s, q = '', n

    while q >= 2 or q < 0:

        q, r = divmod(q, -2)

        if r < 0:

            q += 1

            r += 2

        s += str(r)

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

CROSSREFS

Cf. A039724. Complement of A005352.

Cf. A185269. - Jonathan Vos Post, Feb 19 2011

Sequence in context: A019932 A004447 A258989 * A098882 A254374 A019616

Adjacent sequences:  A005348 A005349 A005350 * A005352 A005353 A005354

KEYWORD

nonn,base,easy,nice,look

AUTHOR

N. J. A. Sloane

EXTENSIONS

More terms from Robert G. Wilson v, Jan 24 2005

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 November 18 17:56 EST 2017. Contains 294894 sequences.