cp's OEIS Frontend

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.

A353139 Digitally balanced numbers (A031443) whose squares are also digitally balanced.

This page as a plain text file.
%I A353139 #15 Apr 28 2022 07:48:58
%S A353139 212,781,794,806,817,838,841,844,865,2962,3101,3130,3171,3178,3185,
%T A353139 3213,3219,3226,3269,3274,3335,3353,3354,3356,3370,3378,3490,3496,
%U A353139 3521,3528,3595,3597,3606,3610,3626,3651,3672,3718,3777,11797,11798,11850,11938,12049
%N A353139 Digitally balanced numbers (A031443) whose squares are also digitally balanced.
%C A353139 Numbers x such that both x and x^2 are terms of A031443, that is, have the same number of 0's as 1's in their binary representations.
%t A353139 balQ[n_] := Module[{d = IntegerDigits[n, 2], m}, EvenQ @ (m = Length @ d) && Count[d, 1] == m/2]; Select[Range[12000], balQ[#] && balQ[#^2] &] (* _Amiram Eldar_, Apr 26 2022 *)
%o A353139 (Python)
%o A353139 from itertools import count, islice
%o A353139 from sympy.utilities.iterables import multiset_permutations
%o A353139 def isbalanced(n): b = bin(n)[2:]; return b.count("0") == b.count("1")
%o A353139 def A031443gen(): yield from (int("1"+"".join(p), 2) for n in count(1) for p in multiset_permutations("0"*n+"1"*(n-1)))
%o A353139 def agen():
%o A353139     for k in A031443gen():
%o A353139         if isbalanced(k**2):
%o A353139             yield k
%o A353139 print(list(islice(agen(), 40))) # _Michael S. Branicky_, Apr 26 2022
%Y A353139 Cf. A031443, A345397.
%K A353139 nonn,base
%O A353139 1,1
%A A353139 _Alex Ratushnyak_, Apr 26 2022