public static void main(String[] args) {
        int largest = 0;

        for (int j = 1; j <= 10000; j++) {
            String pandigital = "";
            int i = 0;

            while (pandigital.length() < 9) {
                pandigital += String.valueOf(j * (++i));
            }

            if (pandigital.length() == 9) {
                boolean valid = true;
                for (int k = 1; k <= 9; k++) {
                    if (!pandigital.contains(Integer.toString(k))) {
                        valid = false;
                        break;
                    }
                }

                if (valid) {
                    if (Integer.parseInt(pandigital) > largest) {
                        largest = Integer.parseInt(pandigital);
                    }
                }

            }
        }

        System.out.println(largest);
    }