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.

A353140 Digitally balanced numbers (A031443) whose squares and cubes are also digitally balanced.

This page as a plain text file.
%I A353140 #15 Apr 28 2022 07:54:54
%S A353140 3274,13453,13492,13706,14726,15113,15498,15528,52049,52251,52330,
%T A353140 52673,52778,53478,53684,53775,53972,54295,54411,54598,54601,55057,
%U A353140 55449,55462,55505,55512,55689,56333,58066,58260,58446,58453,58470,58918,59266,59722,59786
%N A353140 Digitally balanced numbers (A031443) whose squares and cubes are also digitally balanced.
%C A353140 Numbers x such that x, x^2 and x^3 are terms of A031443, that is, have the same number of 0's as 1's in their binary representations.
%t A353140 balQ[n_] := Module[{d = IntegerDigits[n, 2], m}, EvenQ @ (m = Length @ d) && Count[d, 1] == m/2]; Select[Range[60000], balQ[#] && balQ[#^2] && balQ[#^3] &] (* _Amiram Eldar_, Apr 26 2022 *)
%o A353140 (Python)
%o A353140 from itertools import count, islice
%o A353140 from sympy.utilities.iterables import multiset_permutations
%o A353140 def isbalanced(n): b = bin(n)[2:]; return b.count("0") == b.count("1")
%o A353140 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 A353140 def agen():
%o A353140     for k in A031443gen():
%o A353140         if isbalanced(k**2) and isbalanced(k**3):
%o A353140             yield k
%o A353140 print(list(islice(agen(), 40))) # _Michael S. Branicky_, Apr 26 2022
%Y A353140 Cf. A031443, A345397, A353139.
%K A353140 nonn,base
%O A353140 1,1
%A A353140 _Alex Ratushnyak_, Apr 26 2022