OFFSET
1,1
COMMENTS
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.
All terms are between 2^(2k-1/3) and 2^(2k) for some k. - Robert Israel, Nov 26 2025
LINKS
Robert Israel, Table of n, a(n) for n = 1..10000
MAPLE
isdb:= proc(n) local L; L:= convert(n, base, 2); convert(L, `+`) = nops(L)/2 end proc:
select(t -> isdb(t) and isdb(t^2) and isdb(t^3), [seq($ ceil(2^(2*k-1/3)) .. 2^(2*k)-1, k=1..10)]); # Robert Israel, Nov 26 2025
MATHEMATICA
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 *)
PROG
(Python)
from itertools import count, islice
from sympy.utilities.iterables import multiset_permutations
def isbalanced(n): b = bin(n)[2:]; return b.count("0") == b.count("1")
def A031443gen(): yield from (int("1"+"".join(p), 2) for n in count(1) for p in multiset_permutations("0"*n+"1"*(n-1)))
def agen():
for k in A031443gen():
if isbalanced(k**2) and isbalanced(k**3):
yield k
print(list(islice(agen(), 40))) # Michael S. Branicky, Apr 26 2022
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Alex Ratushnyak, Apr 26 2022
STATUS
approved
