package java_programs;
import java.util.*;

public class TO_BASE {
    public static String to_base(int num, int b) {
        if (num == 0) return "0";
        
        String result = "";
        String alphabet = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
        while (num > 0) {
            int i = num % b;
            num = num / b;
            result = alphabet.charAt(i) + result;
        }

        return result;
    }
}