A082978 Duplicate of A005536.
1, 0, 0, 1, 3, 3, 4, 3, 3, 1, 0, 0, 1, 0, 0, 1, 3, 3, 4, 6, 9, 10, 12, 12, 13, 12, 12, 13, 15, 15
Offset: 1
This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.
Alternating bit sum for 11 = 1011 in binary is 1 - 1 + 0 - 1 = -1, so a(11) = -1.
a065359 0 = 0 a065359 n = - a065359 n' + m where (n', m) = divMod n 2 -- Reinhard Zumkeller, Mar 20 2015
A065359 := proc(n) local dgs ; dgs := convert(n,base,2) ; add( -op(i,dgs)*(-1)^i,i=1..nops(dgs)) ; end proc: # R. J. Mathar, Feb 04 2011
f[0]=0; f[n_] := Plus @@ (-(-1)^Range[ Floor[ Log2@ n + 1]] Reverse@ IntegerDigits[n, 2]); Array[ f, 107, 0]
a(n) = my(s=0, u=1); for(k=0,#binary(n)-1,s+=bittest(n,k)*u;u=-u);s /* Washington Bomfim, Jan 18 2011 */
a(n) = my(b=binary(n)); b*[(-1)^k|k<-[-#b+1..0]]~; \\ Ruud H.G. van Tol, Oct 16 2023
a(n) = if(n==0, 0, 2*hammingweight(bitand(n, ((4<<(2*logint(n,4)))-1)/3)) - hammingweight(n)) \\ Andrew Howroyd, Dec 14 2024
def a(n): return sum((-1)**k for k, bi in enumerate(bin(n)[2:][::-1]) if bi=='1') print([a(n) for n in range(107)]) # Michael S. Branicky, Jul 13 2021
from sympy.ntheory import digits def A065359(n): return sum((0,1,-1,0)[i] for i in digits(n,4)[1:]) # Chai Wah Wu, Jul 19 2024
A065359[0] = 0; A065359[n_] := -Total[(-1)^PositionIndex[Reverse[IntegerDigits[n, 2]]][1]]; g[z_] := z/GCD[Re[z], Im[z]]; Module[{n = 0}, Im[NestList[# + g[(1+I)^A065359[n++]] &, 0, 100]]] (* Paolo Xausa, Aug 28 2024 *)
\\ See Links section.
Comments