n to an integer num.num using math.floor(math.log(num, 2)) + 1.k in decreasing order from max_len down to 2.k, set the search range for the base m to be between 2 and num - 1.m for the current k.s, the sum of k 1's in base m.s is equal to num, return m as a string.s is less than num, update the left bound of the search range to mid + 1.s is greater than num, update the right bound of the search range to mid - 1.k, return num - 1 as a string.