A164344 Positive integers whose square contains the same number of 0's as 1's when represented in binary.
3, 7, 13, 15, 25, 29, 31, 54, 57, 61, 63, 103, 110, 113, 118, 121, 125, 127, 199, 203, 207, 212, 213, 214, 218, 230, 238, 241, 246, 249, 253, 255, 389, 393, 394, 395, 402, 404, 409, 421, 431, 433, 435, 439, 458, 468, 478, 481, 486, 494, 497, 502, 505, 509, 511
Offset: 1
Links
- Harvey P. Dale, Table of n, a(n) for n = 1..1000
- James Propp et al., Perfectly balanced perfect squares, math-fun mailing list (archive available to subscribers), Jul 12 2022.
Crossrefs
Programs
-
Mathematica
sn01Q[n_]:=Module[{idn2=IntegerDigits[n^2,2]},Count[idn2,1] == Length[ idn2]/2]; Select[Range[600],sn01Q] (* Harvey P. Dale, Apr 03 2016 *)
-
PARI
select( {is_A164344(n)=hammingweight(n^2)*2==exponent(n^2*2)}, [0..512]) \\ M. F. Hasler, Jul 12 2022
-
Python
def bal(n): return n and n.bit_length() == n.bit_count() * 2 print([k for k in range(512) if bal(k*k)]) # Michael S. Branicky, Jul 12 2022
Formula
{n | n^2 is in A031443} = {n | 2*A000120(n^2) = A070939(n^2)}, i.e., twice the Hamming weight must equal the number of binary digits, for the squares of the terms. - M. F. Hasler, Jul 12 2022
Extensions
More terms from Sean A. Irvine, Oct 08 2009
Comments