login

Reminder: The OEIS is hiring a new managing editor, and the application deadline is January 26.

Smallest square with Hamming weight n (i.e., with exactly n 1's when written in binary).
9

%I #18 Dec 27 2022 16:53:28

%S 0,1,9,25,169,121,441,1521,2025,5625,24025,47089,109561,32761,393129,

%T 851929,1540081,6275025,15327225,27258841,41925625,127893481,

%U 243204025,385611769,998244025,1979449081,4823441401,12870221809,34324602361

%N Smallest square with Hamming weight n (i.e., with exactly n 1's when written in binary).

%C A000120(a(n)) = n.

%H Donovan Johnson, <a href="/A089998/b089998.txt">Table of n, a(n) for n = 0..60</a>

%F a(n) = A231897(n)^2. - _Hugo Pfoertner_, Dec 27 2022

%t a = Table[0, {30}]; Do[c = Count[IntegerDigits[n^2, 2], 1]; If[ a[[c + 1]] == 0, a[[c + 1]] = n^2; Print[c, " = ", n^2]], {n, 1, 360000}] (* _Robert G. Wilson v_, Dec 03 2003 *)

%t Join[{0},With[{s=DigitCount[Range[400000]^2,2,1]},Flatten[Table[ Position[ s,_?(#==n&),1,1],{n,30}]]]^2] (* _Harvey P. Dale_, Mar 03 2013 *)

%Y Cf. A000290, A089999, A061712, A090001, A231897.

%K nonn,base

%O 0,3

%A _Reinhard Zumkeller_, Nov 20 2003

%E More terms from _Robert G. Wilson v_, Dec 03 2003

%E Offset corrected by _Donovan Johnson_, May 01 2012