A365214
Least k such that the binary representation of 3^k has exactly n 1's, or -1 if no such k exists.
Original entry on oeis.org
0, 1, 4, 3, 7, 5, -1, 9, 10, 12, 13, -1, 11, 14, 15, 24, 19, 25, 22, 21, -1, 23
Offset: 1
A365215
Largest k such that the binary representation of 3^k has exactly n 1's, or -1 if no such k exists.
Original entry on oeis.org
0, 2, 4, 3, 7, 8, -1, 9, 10, 12, 16, -1, 11, 18, 15, 24, 20, 25, 22, 21, -1, 23
Offset: 1
-
LargestK[n_Integer] := Module[{k = 1000(*Assuming 1000 is large enough for the search. Adjust if necessary.*), binCount}, While[k >= 0, binCount = Total[IntegerDigits[3^k, 2]]; If[binCount == n, Return[k]]; k--;]; -1]; Table[LargestK[n], {n, 22}] (* Robert P. P. McKone, Aug 26 2023 *)
Showing 1-2 of 2 results.
Comments