login
Alternating sum of "negabits". Replace (-2)^k with (-1)^k in negabinary expansion of n.
2

%I #11 Jan 30 2020 06:43:31

%S 1,0,1,1,2,-1,0,0,1,0,1,1,2,0,1,1,2,1,2,2,3,-2,-1,-1,0,-1,0,0,1,-1,0,

%T 0,1,0,1,1,2,-1,0,0,1,0,1,1,2,0,1,1,2,1,2,2,3,-1,0,0,1,0,1,1,2,0,1,1,

%U 2,1,2,2,3,0,1,1,2,1,2,2,3,1,2,2,3,2,3,3,4,-3,-2,-2,-1,-2,-1,-1,0,-2,-1,-1,0,-1,0,0,1,-2,-1,-1,0,-1,0,0

%N Alternating sum of "negabits". Replace (-2)^k with (-1)^k in negabinary expansion of n.

%C Notation: (-2)[n](-1)

%H Amiram Eldar, <a href="/A065360/b065360.txt">Table of n, a(n) for n = 1..10000</a>

%e 6 = 11010 -> +(1)-(1)+(0)-(1)+(0) = -1 = a(6).

%o (PARI) negab(n)=if(n, negab(n\(-2))*10+bittest(n, 0)); \\ A039724

%o a(n) = my(d=Vecrev(digits(negab(n)))); sum(k=1, #d, d[k]*(-1)^(k-1)); \\ _Michel Marcus_, Aug 28 2019

%Y Cf. A005351, A039724, A065359.

%K base,easy,sign

%O 1,5

%A _Marc LeBrun_, Oct 31 2001