A027615 Number of 1's when n is written in base -2.
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
Examples
A039724(7) = 11011 which has four 1's, so a(7) = 4.
References
- J.-P. Allouche and J. Shallit, Automatic Sequences, Cambridge Univ. Press, 2003, p. 164.
Links
- Jianing Song, Table of n, a(n) for n = 0..10000
- Eric Weisstein's World of Mathematics, Negabinary.
- Wikipedia, Negative base.
Programs
-
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 *)
-
PARI
a(n) = if(n==0, 0, a(n\(-2))+n%2) /* Jianing Song, Oct 18 2018 */
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
Comments