public static List<Pair<Integer, Integer>> factorize(int n) {
        notNegativeCheck(n);
        final List<Pair<Integer, Integer>> factors = new ArrayList<>();
        if (n < 4) {
            factors.add(new Pair<>(n, 1));
            return factors;
        }
        
        for (int i = 2; i <= n; ++i) {
            final Pair<Integer, Integer> factor = new Pair<>(i, 0);
            boolean factorFound = false;
            while (n % i == 0) {
                factorFound = true;
                factor.setSecond(factor.getSecond() + 1);
                n /= i;
            }
            if (factorFound)
                factors.add(factor);
        }
        return factors;
    }