login
Integers n such that s(n^2) = s(n)*(s(n)+1)/2, where s(n) is the sum of binary digits of n (A000120).
1

%I #54 Feb 03 2021 19:59:19

%S 0,1,2,4,5,8,9,10,16,17,18,20,21,32,33,34,36,37,40,42,64,65,66,68,69,

%T 72,73,74,80,81,84,128,129,130,132,133,136,137,138,144,146,148,160,

%U 161,162,168,256,257,258,260,261,264,265,266,272,273,274,276,277,288,289,292,293,296,320,321,322,324,336,337,512,513,514,516

%N Integers n such that s(n^2) = s(n)*(s(n)+1)/2, where s(n) is the sum of binary digits of n (A000120).

%C Also, integers n such that A159918(n) = A000217(A000120(n)).

%C For any n, s(n^2) <= s(n)*(s(n)+1)/2. This sequence gives n for which the equality is achieved.

%H Alois P. Heinz, <a href="/A340956/b340956.txt">Table of n, a(n) for n = 1..10000</a>

%p q:= n-> (s-> is(s(n^2)=(t->t(s(n)))(h->h*(h+1)/2)))(

%p k-> add(i, i=Bits[Split](k))):

%p select(q, [$0..555])[]; # _Alois P. Heinz_, Feb 01 2021

%t s[n_] := DigitCount[n, 2, 1]; t[n_] := n*(n + 1)/2; Select[Range[0, 500], s[#^2] == t[s[#]] &] (* _Amiram Eldar_, Feb 01 2021 *)

%o (PARI) isok(n) = my(hn=hammingweight(n)); hammingweight(n^2) == hn*(hn+1)/2; \\ _Michel Marcus_, Feb 01 2021

%Y Cf. A000120, A000217, A000290, A159918.

%K nonn,base

%O 1,3

%A _Max Alekseyev_, Feb 01 2021