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 A358857 #19 Dec 04 2022 13:05:34 %S A358857 2,-1,49,-1,2,2,535,-1,3843,899,49,197,12,52,9,-1,9,10,2,9,2,2,35,9,2, %T A358857 2,147,2,2141,2095,32991,-1,258055,63495,3849,15367,961,906,226,3603, %U A358857 56,201,49,197,49,49,50,789,56,56,42,209,50,42,44,41,10,12,10,41 %N A358857 Least integer k in A031443 such that k*n is also in A031443, or -1 if there is no such k. %C A358857 It's clear that a(2^i)=-1 if i>0, because 2^i*n always has more 0's than n does. I do not know if every number other than a power %C A358857 of 2 has such a k. Local maxima seem to be near odd powers of 2. It is not hard to show that a(2^n +- 1)!=-1 for n>=1. %H A358857 Rémy Sigrist, <a href="/A358857/b358857.txt">Table of n, a(n) for n = 1..10000</a> %H A358857 Rémy Sigrist, <a href="/A358857/a358857.gp.txt">PARI program</a> %F A358857 a(n) = A358858(n)/n unless a(n) = -1. - _Pontus von Brömssen_, Dec 03 2022 %e A358857 For n = 3 both 49 = [110001] and 49*3 = [10010011] have the same number of 0's as 1's, and this is the least such. %o A358857 (Python) %o A358857 from itertools import count %o A358857 from sympy.utilities.iterables import multiset_permutations %o A358857 def isbalanced(n): b = bin(n)[2:]; return b.count("0") == b.count("1") %o A358857 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 A358857 def a(n): %o A358857 if n > 1 and bin(n)[2:].strip("0") == "1": return -1 %o A358857 return next(k for k in A031443gen() if isbalanced(k*n)) %o A358857 print([a(n) for n in range(1, 61)]) # _Michael S. Branicky_, Dec 03 2022 %o A358857 (PARI) See Links section. %Y A358857 Cf. A031443, A358858. %K A358857 sign,base %O A358857 1,1 %A A358857 _Jeffrey Shallit_, Dec 03 2022