private boolean isPower(int n) {

            if (n == 0 || n == 1) return true;
            HashMap<Integer, Integer> frequencyMap = new HashMap<>();

            for (int i = 2; i <= n; i++) {
                while (n % i == 0) {

                    if (frequencyMap.get(i) == null)
                        frequencyMap.put(i, 1);
                    else
                        frequencyMap.put(i, frequencyMap.get(i) + 1);
                    n = n / i;
                }
            }

            List<Integer> frequencies = new ArrayList<>(frequencyMap.values());
            Collections.sort(frequencies);

            if (frequencies.isEmpty() || frequencies.get(0) == 1) return false;
            else {
                int result = frequencies.get(0);
                for (int i = 1; i < frequencies.size(); i++) {
                    result = gcd(result, frequencies.get(i));
                }
                if (result > 1) return true;
                else return false;
            }
        }