%I M3225 #34 May 08 2023 02:01:35
%S 1,0,4,4,5,0,12,16,21,16,24,20,17,0,32,48,65,64,84,84,85,64,92,96,101,
%T 80,88,68,49,0,80,128,177,192,244,260,277,256,316,336,357,336,360,340,
%U 321,256,336,368,401,384,420,404,389,320,364,352,341,272,264,196
%N a(n) = Sum_{k=1..n-1} (k AND n-k).
%D _Marc LeBrun_, personal communication.
%D N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).
%H Alois P. Heinz, <a href="/A006581/b006581.txt">Table of n, a(n) for n = 2..8191</a>
%H Hsien-Kuei Hwang, Svante Janson, and Tsung-Hsi Tsai, <a href="https://arxiv.org/abs/2210.10968">Identities and periodic oscillations of divide-and-conquer recurrences splitting at half</a>, arXiv:2210.10968 [cs.DS], 2022, pp. 6, 24, 38-39, 64.
%H M. Le Brun, <a href="/A006577/a006577.pdf">Email to N. J. A. Sloane, Jul 1991</a>
%F G.f.: 1/(1-x)^2 * Sum_{k>=0} 2^k*t^2/(1+t)^2, t = x^2^k. - _Ralf Stephan_, Feb 12 2003
%F a(0) = a(1) = 0, a(2n) = 2*a(n-1) + 2*a(n) + n, a(2n+1) = 4*a(n).
%F a(n) = 2*(Sum_{k=1..floor((n-1)/2)} k AND n-k) + m where m = 0 if n is odd and n/2 otherwise. - _Chai Wah Wu_, May 07 2023
%t Array[Sum[BitAnd[k, # - k], {k, # - 1}] &, 60, 2] (* _Michael De Vlieger_, Oct 27 2022 *)
%o (Python)
%o def A006581(n): return (sum(k&n-k for k in range(1,n+1>>1))<<1)+(0 if n&1 else n>>1) # _Chai Wah Wu_, May 07 2023
%Y Cf. A090889(n) - A000292(n-2).
%Y Antidiagonal sums of array A003985.
%K nonn
%O 2,3
%A _N. J. A. Sloane_