code: public static String convert( long x, int n, String d ) {
          if (x == 0) {
              return "0";
          }
  
          String r = "";
          int m = 1 << n;
          m--;
          while( x != 0 ) {
              r = d.charAt((int) (x & m)) + r;
              x = x >>> n;
          }
          return r;
      }
docs: Converts number to string
  
  @param x      value to convert
  @param n      conversion base
  @param d      string with characters for conversion.
  
  @return converted number as string