Write a recursive method, numToString, that takes two arguments: num, the number to convert, and base, the base to represent the number in. For instance, calling numToString(10, 2) returns the decimal number 10 as the base-two (binary) string "1010". Your method should work with any base 2 <= base <= 36. g

Respuesta :

Answer:

This is the required code:

Explanation:

public class NumberToString {

   public static String numToString(int num, int base) {

       final String digits = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";

       if (num < base) {

           return "" + digits.charAt(num);

       } else {

           return numToString(num / base, base) + digits.charAt(num % base);

       }

   }

}