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

 

Logo

Thanks to everyone who made a donation during our annual appeal!
To see the list of donors, or make a donation, see the OEIS Foundation home page.

Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A039724 Numbers in base -2. 30

%I

%S 0,1,110,111,100,101,11010,11011,11000,11001,11110,11111,11100,11101,

%T 10010,10011,10000,10001,10110,10111,10100,10101,1101010,1101011,

%U 1101000,1101001,1101110,1101111,1101100,1101101,1100010,1100011,1100000,1100001,1100110,1100111,1100100

%N Numbers in base -2.

%C a(A007583(n)) are the only terms with all 1s digits; the number of digits = 2n + 1. - _Bob Selcoe_, Aug 21 2016

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

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

%H William A. Tedeschi, <a href="/A039724/b039724.txt">Table of n, a(n) for n = 0..10000</a>

%H Joerg Arndt, <a href="http://www.jjj.de/fxt/#fxtbook">Matters Computational (The Fxtbook)</a>, p. 58-59

%H Jaime Rangel-Mondragon, <a href="http://demonstrations.wolfram.com/NegabinaryNumbersToDecimal/">Negabinary Numbers to Decimal</a>

%H Vladimir Shevelev, <a href="http://arxiv.org/abs/1603.04434">Two analogs of Thue-Morse sequence</a>, arXiv:1603.04434 [math.NT], 2016.

%H Eric Weisstein's World of Mathematics, <a href="http://mathworld.wolfram.com/Negabinary.html">Negabinary</a>

%H Wikipedia, <a href="http://en.wikipedia.org/wiki/Negative_base">Negative base</a>

%F G.f. g(x) satisfies g(x) = (x + 10*x^2 + 11*x^3)/(1 - x^4) + 100(1 + x + x^2 + x^3)*g(x^4)/x^2. - _Robert Israel_, Feb 24 2016

%e 2 = 4 + (-2) + 0 = 110_(-2), 3 = 4 + (-2) + 1 = 111_(-2), ..., 6 = 16 + (-8) + 0 + (-2) + 0 = 11010_(-2).

%p f:= proc(n) option remember; 10*floor((n mod 4)/2) + (n mod 2) + 100*procname(round(n/4)) end proc:

%p f(0):= 0:

%p seq(f(i),i=0..100); # _Robert Israel_, Feb 24 2016

%t ToNegaBases[ i_Integer, b_Integer ] := FromDigits[ Rest[ Reverse[ Mod[ NestWhileList[ (#1 - Mod[ #1, b ])/-b &, i, #1 != 0 & ], b ] ] ] ]; Table[ ToNegaBases[ n, 2 ], {n, 0, 31} ]

%o (Haskell)

%o a039724 0 = 0

%o a039724 n = a039724 n' * 10 + m where

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

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

%o -- _Reinhard Zumkeller_, Jul 07 2012

%o (Python)

%o def A039724(n):

%o s, q = '', n

%o while q >= 2 or q < 0:

%o q, r = divmod(q, -2)

%o if r < 0:

%o q += 1

%o r += 2

%o s += str(r)

%o return int(str(q)+s[::-1]) # _Chai Wah Wu_, Apr 09 2016

%o (PARI) A039724(n)=if(n,A039724(n\(-2))*10+bittest(n,0)) \\ _M. F. Hasler_, Oct 16 2018

%Y Nonnegative numbers in negative bases: A039723 (b=-10), this sequence (b=-2), A073785 (b=-3), A007608 (b=-4), A073786 (b=-5), A073787 (b=-6), A073788 (b=-7), A073789 (b=-8), A073790 (b=-9).

%Y Cf. A212529 (negative numbers in base -2).

%Y Cf. A005351, A007583.

%K base,nice,nonn,easy

%O 0,3

%A Robert Lozyniak (11(AT)onna.com)

%E More terms from _Eric W. Weisstein_

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

License Agreements, Terms of Use, Privacy Policy. .

Last modified January 16 21:37 EST 2019. Contains 319206 sequences. (Running on oeis4.)