这是计算十进制数的基本版本的代码。我不确定它的时间复杂度。谢谢,
public static String convertToBase(int num, int base) {
if (base > 36) {
throw new IllegalArgumentException("The input argument should be less than or equal to 36.");
}
final StringBuilder sb = new StringBuilder();
while (num > 0) {
final int div = num % base;
if (div > 9) {
final int sum = div + 55;
sb.append((char) sum);
} else {
sb.append(div);
}
num = num / base;
}
return sb.reverse().toString();
}