OFFSET
1,1
COMMENTS
Clearly a(2^i)=-1 for i>0, since x*2^i has more 0's than x does. I do not know that there is such an m for all n, although it exists up to n=513.
LINKS
Rémy Sigrist, Table of n, a(n) for n = 1..10000
Rémy Sigrist, PARI program
FORMULA
a(n) = n*A358857(n) unless a(n) = -1. - Pontus von Brömssen, Dec 03 2022
EXAMPLE
For n = 3 both 147 and 147/3=49 are in A031443.
PROG
(Python)
from itertools import count
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 a(n):
if n > 1 and bin(n)[2:].strip("0") == "1": return -1
return next(k*n for k in A031443gen() if isbalanced(k*n))
print([a(n) for n in range(1, 47)]) # Michael S. Branicky, Dec 03 2022
(PARI) See Links section.
CROSSREFS
KEYWORD
sign,base
AUTHOR
Jeffrey Shallit, Dec 03 2022
STATUS
approved