%I #60 Mar 18 2023 08:49:14
%S 0,1,2,3,4,6,7,8,12,14,15,16,24,28,30,31,32,48,56,60,62,63,64,79,91,
%T 96,112,120,124,126,127,128,157,158,159,182,183,187,192,224,240,248,
%U 252,254,255,256,279,287,314,316,317,318,319,351,364,365,366,374,375,379,384
%N Let B(n) be the sum of binary digits of n. This sequence contains n such that B(n) = B(n^2).
%C Superset of A023758.
%C Hare, Laishram, & Stoll show that this sequence contains infinitely many odd numbers. In particular for each k in {12, 13, 16, 17, 18, 19, 20, ...} there are infinitely many terms in this sequence with binary digit sum k. - _Charles R Greathouse IV_, Aug 25 2015
%H Reinhard Zumkeller, <a href="/A077436/b077436.txt">Table of n, a(n) for n = 1..10476, all terms <= 2^20</a>
%H Karam Aloui, Damien Jamet, Hajime Kaneko, Steffen Kopecki, Pierre Popoli, and Thomas Stoll, <a href="https://arxiv.org/abs/2203.05451">On the binary digits of n and n^2</a>, arXiv:2203.05451 [math.NT], 2022.
%H K. G. Hare, S. Laishram, and T. Stoll, <a href="http://arxiv.org/abs/1001.4170">The sum of digits of n and n^2</a>, International Journal of Number Theory 7:7 (2011), pp. 1737-1752.
%H Giuseppe Melfi, <a href="https://arxiv.org/abs/math/0402458">On simultaneous binary expansions of n and n^2</a>, arXiv:math/0402458 [math.NT], 2004.
%H Giuseppe Melfi, <a href="http://melfi.150m.com/presentazione.pdf">Su alcune successioni di interi</a> (English with an Italian title)
%F A159918(a(n)) = A000120(a(n)). - _Reinhard Zumkeller_, Apr 25 2009
%e The element 79 belongs to the sequence because 79=(1001111) and 79^2=(1100001100001), so B(79)=B(79^2)
%p select(t -> convert(convert(t,base,2),`+`) = convert(convert(t^2,base,2),`+`), [$0..1000]); # _Robert Israel_, Aug 27 2015
%t t={}; Do[If[DigitCount[n, 2, 1] == DigitCount[n^2, 2, 1], AppendTo[t, n]], {n, 0, 364}]; t
%t f[n_] := Total@ IntegerDigits[n, 2]; Select[Range[0, 384], f@ # == f[#^2] &] (* _Michael De Vlieger_, Aug 27 2015 *)
%o (Haskell)
%o import Data.List (elemIndices)
%o import Data.Function (on)
%o a077436 n = a077436_list !! (n-1)
%o a077436_list = elemIndices 0
%o $ zipWith ((-) `on` a000120) [0..] a000290_list
%o -- _Reinhard Zumkeller_, Apr 12 2011
%o (PARI) is(n)=hammingweight(n)==hammingweight(n^2) \\ _Charles R Greathouse IV_, Aug 25 2015
%o (Magma) [n: n in [0..400] | &+Intseq(n, 2) eq &+Intseq(n^2, 2)]; // _Vincenzo Librandi_, Aug 30 2015
%o (Python)
%o def ok(n): return bin(n).count('1') == bin(n**2).count('1')
%o print([m for m in range(400) if ok(m)]) # _Michael S. Branicky_, Mar 11 2022
%Y Cf. A058369, A000120, A000290, A083567.
%Y Cf. A211676 (number of n-bit numbers in this sequence).
%Y A261586 is a subsequence. Subsequence of A352084.
%K easy,nonn,base
%O 1,3
%A _Giuseppe Melfi_, Nov 30 2002
%E Initial 0 added by _Reinhard Zumkeller_, Apr 28 2012, Apr 12 2011