public static void main(String[] args) {
		List<String> numbers = new ArrayList<>();
		for (int i = 1; i < 10; i++) {
			numbers.add("" + i);
		}

		Set<Integer> products = new HashSet<>();

		List<String> pandigitals = permute("", numbers);

		for (String pandigital : pandigitals) {
			for (int i = pandigital.length() - 4; i > 3; i--) {
				int sum = Integer.valueOf(pandigital.substring(i));
				for (int j = i - 1; j > 0; j--) {
					int x = Integer.valueOf(pandigital.substring(0, j));
					int y = Integer.valueOf(pandigital.substring(j, i));

					if (x * y == sum) {
						System.out.println("" + x + " * " + y + " = " + sum);
						products.add(sum);
					}
				}
			}
		}

		int sum = 0;

		for (int product : products) {
			sum += product;
		}

		System.out.println("Result = " + sum);
	}