Reminder: The OEIS is hiring a new managing editor, and the application deadline is January 26.
%I #18 Mar 05 2023 01:57:32
%S 0,0,0,0,0,1,0,0,0,1,1,2,0,1,0,0,0,1,1,2,1,3,2,-1,0,2,1,2,0,1,0,0,0,1,
%T 1,2,1,3,2,3,1,2,3,3,2,4,-1,-1,0,2,2,1,1,4,2,2,0,2,1,2,0,1,0,0,0,1,1,
%U 2,1,3,2,3,1,3,3,5,2,3,3,0,1,3,2,4,3,3,3,2,2,5,4,0,-1,1,-1,-1,0,2,2,2
%N a(n) = wt(n^2) - wt(n), where wt(n) = A000120(n) is the binary weight function.
%C A077436 lists n for which a(n) = 0.
%C A094694 lists n for which a(n) < 0.
%H Dumitru Damian, <a href="/A232243/b232243.txt">Table of n, a(n) for n = 0..10000</a>
%F a(n) = A159918(n) - A000120(n).
%e a(5): 5 = 101_2, 25 = 11001_2, so a(5) = 3 - 2 = 1.
%e a(23): 23 = 10111_2, 529 = 10001001_2, so a(23) = 3 - 4 = -1.
%o (JavaScript)
%o function bitCount(n) {
%o var i,c,s;
%o c=0;
%o s=n.toString(2);
%o for (i=0;i<s.length;i++)
%o if (s.charAt(i)==1)
%o c++;
%o return c;
%o }
%o for (i=0;i<100;i++) document.write(bitCount(i*i)-bitCount(i)+", ");
%o (Python)
%o def A232243(n): return (n**2).bit_count()-n.bit_count()
%o print(list(A232243(n) for n in range(10**2))) # _Dumitru Damian_, Mar 04 2023
%o (PARI) a(n) = hammingweight(n^2) - hammingweight(n); \\ _Michel Marcus_, Mar 05 2023
%Y Cf. A000120, A159918, A077436, A094694, A231898.
%K sign,base
%O 0,12
%A _Jon Perry_, Nov 20 2013