Loading...
Loading...
Loading...
Break a number into its prime factors. Print each prime as p when it appears once, or p^e when it appears e times, in increasing order, separated by spaces.
2^3 3^2 5.Example
Input
360
Output
2^3 3^2 5
360 = 2^3 * 3^2 * 5.
Try the problem first. Open one hint at a time.
Divide n by d = 2, 3, ... as long as d fits, counting how many times.
Stop when d * d is above what is left of n; a remainder above 1 is itself a prime.
Write your Python code, run it on the examples and submit it to hidden tests.
Solve in the editor