Editorial for JDCC '16 Contest 4 P3 - Big Integer Factorization
Submitting an official solution before solving the problem yourself is a bannable offence.
If the prime factorization of a number is , then the prime factorization of is .
We just need to find the prime factorization of and multiply each power by when we print it. There is at most one prime factor greater than . Thus, we loop through all the whole numbers from to and check if it divides evenly. If so, then store how many times this number divides it. Divide the number by the factors (as many times as the power) while searching so that we only have prime factors in our list. After we are done searching all the numbers and if the number is not 1, then it means this is the greatest factor.