login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

A027615
Number of 1's when n is written in base -2.
12
0, 1, 2, 3, 1, 2, 3, 4, 2, 3, 4, 5, 3, 4, 2, 3, 1, 2, 3, 4, 2, 3, 4, 5, 3, 4, 5, 6, 4, 5, 3, 4, 2, 3, 4, 5, 3, 4, 5, 6, 4, 5, 6, 7, 5, 6, 4, 5, 3, 4, 5, 6, 4, 5, 3, 4, 2, 3, 4, 5, 3, 4, 2, 3, 1, 2, 3, 4, 2, 3, 4, 5, 3, 4, 5, 6, 4, 5, 3, 4, 2
OFFSET
0,3
COMMENTS
Base -2 is also called "negabinary".
From Jianing Song, Oct 18 2018: (Start)
Define f(n) as: f(0) = 0, f(-2*n) = f(n), f(-2*n+1) = f(n) + 1, then a(n) = f(n), n >= 0. See A320642 for the other half of f.
For k > 0, the earliest occurrence of k is n = A305750(k).
Conjecture: a(n) != A053737(n) if and only if there exists even k >= 4 such that n mod 2^k >= (5*2^(k+1) + 2)/3. If this holds, then the probability of a random chosen number n to satisfy a(n) != A053737(n) is 1/6. (End)
REFERENCES
J.-P. Allouche and J. Shallit, Automatic Sequences, Cambridge Univ. Press, 2003, p. 164.
LINKS
Eric Weisstein's World of Mathematics, Negabinary.
Wikipedia, Negative base.
FORMULA
a(n) = 3*A072894(n+1) - 2*n - 3. Proof by Nikolaus Meyberg, following a conjecture by Ralf Stephan. - R. J. Mathar, Jan 11 2013
a(n) == n (mod 3). - Jianing Song, Oct 18 2018
a(n) = A000120(A005351(n)). - Michel Marcus, Oct 23 2018
EXAMPLE
A039724(7) = 11011 which has four 1's, so a(7) = 4.
MATHEMATICA
a[n_] := a[n] = a[Quotient[n - 1, -2]] + Mod[n, 2]; a[0] = 0; Array[a, 100, 0] (* Amiram Eldar, Jul 23 2023 *)
PROG
(PARI) a(n) = if(n==0, 0, a(n\(-2))+n%2) /* Jianing Song, Oct 18 2018 */
KEYWORD
nonn,base
AUTHOR
STATUS
approved