This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.
%I A061656 #23 Feb 27 2023 15:54:45 %S A061656 53,106,211,212,397,403,417,419,422,424,437,441,459,781,794,801,806, %T A061656 817,833,834,838,839,841,844,848,865,874,882,885,918,979,1481,1549, %U A061656 1562,1565,1571,1573,1585,1588,1589,1602,1612,1613,1634,1637,1665,1666,1667,1668 %N A061656 Numbers k > 1 such that, in base 2, k and k^2 contain the same digits in the same proportion. %H A061656 Alois P. Heinz, <a href="/A061656/b061656.txt">Table of n, a(n) for n = 1..10000</a> %e A061656 53 = 110101_2 and 53^2 = 101011111001_2. %p A061656 p:= n-> add(x^i, i=convert(n, base, 2)): %p A061656 a:= proc(n) option remember; local k; %p A061656 for k from 1+`if`(n=1, 0, a(n-1)) %p A061656 while p(k)*2<>p(k^2) do od; k %p A061656 end: %p A061656 seq(a(n), n=1..50); # _Alois P. Heinz_, May 10 2015 %t A061656 b2pQ[n_]:=Module[{bn=IntegerDigits[n,2],b2n=IntegerDigits[n^2,2], cbn0, cb2n0}, cbn0=Count[bn,0];cb2n0=Count[b2n,0];cbn0>0&&cb2n0>0 && Count[ bn,1]/cbn0==Count[b2n,1]/cb2n0]; Select[Range[1700],b2pQ] (* _Harvey P. Dale_, Jan 25 2012 *) %o A061656 (Python) %o A061656 from fractions import Fraction %o A061656 from itertools import count, islice %o A061656 def f(i, j): %o A061656 bi, bj = bin(i)[2:], bin(j)[2:] %o A061656 pi = [Fraction(bi.count(d), len(bi)) for d in "01"] %o A061656 pj = [Fraction(bj.count(d), len(bj)) for d in "01"] %o A061656 return pi == pj %o A061656 def ok(n): return f(n, n**2) %o A061656 print([k for k in range(2, 1700) if ok(k)]) # _Michael S. Branicky_, Feb 27 2023 %Y A061656 Cf. A061657, A061658, A061659, A061660, A061661, A061662, A061663, A114258, A061664. %K A061656 base,easy,nonn %O A061656 1,1 %A A061656 _Erich Friedman_, Jun 16 2001 %E A061656 Offset changed to 1 by _Alois P. Heinz_, May 10 2015