public static String toRoman(int number) 
    {
        if (number < 0 || number >= MAX*4) 
        {
            throw new IllegalArgumentException("toRoman: " + number + " is not between 0 and " + (MAX*4-1));
        }
        if (number == 0) return "N";
        StringBuilder sb = new StringBuilder();
        int i = 0, m = MAX;
        while (number > 0) 
        {
            int[] d = DIGITS[number / m];
            for (int n: d) sb.append(R[i-n]);
            number %= m;
            m /= 10;
            i += 2;
        }
        
        return sb.toString();
    }