package ua.nure.jfn.task1;

public class Part4 {

    public static void main(String[] args) {
        int num = Part2.parseInt(args[0]);

        System.out.printf("%d = ", num);

        int counter;
        for (int prime = 2; num != 1; prime = nextPrime(prime)) {
            for (counter = 0; num % prime == 0; counter++)
                num /= prime;

            if (counter != 0)
                System.out.printf("%d^%d%s", prime, counter, num != 1 ? " x " : "");
        }
    }

    public static int nextPrime(int x) {
        for (x += 1; !Part3.isPrime(x); x += 1)
            ;

        return x;
    }
}
