A159918 Number of ones in binary representation of n^2.
0, 1, 1, 2, 1, 3, 2, 3, 1, 3, 3, 5, 2, 4, 3, 4, 1, 3, 3, 5, 3, 6, 5, 3, 2, 5, 4, 6, 3, 5, 4, 5, 1, 3, 3, 5, 3, 6, 5, 7, 3, 5, 6, 7, 5, 8, 3, 4, 2, 5, 5, 5, 4, 8, 6, 7, 3, 6, 5, 7, 4, 6, 5, 6, 1, 3, 3, 5, 3, 6, 5, 7, 3, 6, 6, 9, 5, 7, 7, 5, 3, 6, 5, 8, 6, 7, 7, 7, 5, 9, 8, 5, 3, 6, 4, 5, 2, 5, 5, 6, 5, 9, 5, 7, 4
Offset: 0
References
- L. Szalay, The equations 2^n ± 2^m ± 2^l = z^2, Indagationes Mathematicae (N.S.) 13, no. 1 (2002), pp. 131-142.
Links
- Nathaniel Johnston, Table of n, a(n) for n = 0..10000
- Bernt Lindström, On the binary digits of a power, Journal of Number Theory, Volume 65, Issue 2, August 1997, Pages 321-324.
- Nick MacKinnon, Problems and Solutions #12140, The American Mathematical Monthly, 126:9 (2019), 850.
- K. B. Stolarsky, The binary digits of a power, Proc. Amer. Math. Soc. 71 (1978), 1-5.
- Index entries for sequences related to binary expansion of n
Crossrefs
Programs
-
Haskell
a159918 = a000120 . a000290 -- Reinhard Zumkeller, Oct 12 2013
-
Maple
A159918 := proc(n) return add(b, b=convert(n^2, base, 2)): end: seq(A159918(n), n=0..100); # Nathaniel Johnston, Jun 23 2011
-
Mathematica
a[n_] := Total[IntegerDigits[n^2, 2]]; Table[a[n], {n, 0, 100}] (* Jean-François Alcover, Oct 27 2021 *)
-
PARI
a(n)=hammingweight(n^2) \\ Charles R Greathouse IV, Aug 06 2015
-
Python
def A159918(n): return bin(n*n).count('1') # Chai Wah Wu, Sep 03 2014
Formula
Lindström shows that lim sup wt(m^2)/log_2 m = 2. - N. J. A. Sloane, Oct 11 2013
a(n) = [x^(n^2)] (1/(1 - x))*Sum_{k>=0} x^(2^k)/(1 + x^(2^k)). - Ilya Gutkovskiy, Mar 27 2018
Comments