A320642 Number of 1's in the base-(-2) expansion of -n.
2, 1, 3, 2, 4, 3, 2, 1, 3, 2, 4, 3, 5, 4, 3, 2, 4, 3, 5, 4, 6, 5, 4, 3, 5, 4, 3, 2, 4, 3, 2, 1, 3, 2, 4, 3, 5, 4, 3, 2, 4, 3, 5, 4, 6, 5, 4, 3, 5, 4, 6, 5, 7, 6, 5, 4, 6, 5, 4, 3, 5, 4, 3, 2, 4, 3, 5, 4, 6, 5, 4, 3, 5, 4, 6, 5, 7, 6, 5, 4, 6, 5, 7, 6, 8, 7, 6
Offset: 1
Examples
A212529(11) = 110101 which has four 1's, so a(11) = 4. A212529(25) = 111011 which has five 1's, so a(25) = 5. A212529(51) = 11011101 which has six 1's, so a(51) = 6.
Links
- Jianing Song, Table of n, a(n) for n = 1..10000
- Eric Weisstein's World of Mathematics, Negabinary.
- Eric Weisstein's World of Mathematics, Negadecimal.
- Wikipedia, Negative base.
Programs
-
Mathematica
b[n_] := b[n] = b[Quotient[n - 1, -2]] + Mod[n, 2]; b[0] = 0; a[n_] := b[-n]; Array[a, 100] (* Amiram Eldar, Jul 23 2023 *)
-
PARI
b(n) = if(n==0, 0, b(n\(-2))+n%2) a(n) = b(-n)
Formula
a(n) == -n (mod 3).
Comments