login
Characteristic function of numbers with binary weight 2 (A018900).
5

%I #12 Mar 31 2021 04:34:25

%S 0,0,0,1,0,1,1,0,0,1,1,0,1,0,0,0,0,1,1,0,1,0,0,0,1,0,0,0,0,0,0,0,0,1,

%T 1,0,1,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,

%U 1,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0

%N Characteristic function of numbers with binary weight 2 (A018900).

%C a(A018900(n)) = 1; a(A161989(n)) = 0. - _Reinhard Zumkeller_, Jun 24 2009

%H R. Zumkeller, <a href="/A151774/b151774.txt">Table of n, a(n) for n = 0..10000</a>

%H <a href="/index/Ch#char_fns">Index entries for characteristic functions</a>

%F Let Theta = Sum_{k >= 0} x^(2^k). G.f. is (x + Theta^2 - Theta)/2 (cf. A151758).

%t w[n_] := IntegerDigits[n, 2] // Total;

%t a[n_] := Boole[w[n] == 2];

%t a /@ Range[0, 105] (* _Jean-François Alcover_, Mar 31 2021 *)

%o (PARI) a(n)=hammingweight(n)==2 \\ _Charles R Greathouse IV_, Sep 26 2015

%Y Cf. A000120, A018900, A151758.

%K nonn,easy

%O 0,1

%A _N. J. A. Sloane_, Jun 23 2009