I am trying to convert a base 10 number to any base by using conversion. Right now this is the code I have came up with. I have a sad feeling this may be completely wrong. The
I just finished doing this problem for a comp sci class. I had to solve this recursively:
public static String convert(int number, int base)
{
int quotient = number / base;
int remainder = number % base;
if (quotient == 0) // base case
{
return Integer.toString(remainder);
}
else
{
return convert(quotient, base) + Integer.toString(remainder);
}
}