In the hidden laboratory beneath the ancient library of Prime City, the Royal Alchemist stirs a bubbling cauldron of liquid numbers. The kingdom's treasury vault can only be opened by a secret formula: every number must be broken down into its purest prime ingredients before it can be forged into a key. The alchemist hands you a worn parchment. "Every number," she whispers, "can be expressed as a product of primes. This is the Fundamental Theorem of Arithmetic ÔÇö the bedrock of all number theory. Find the prime factorization of the number I give you, and the vault shall open." Given an integer N, output its prime factorization in the format p1^e1 p2^e2 ... where pi are primes in ascending order and ei are their exponents. If an exponent is 1, output just the prime without ^1. The alchemist's notes warn of these constraints: 2 <= N <= 10^12 From the alchemist's log, these examples have been verified: Input: 12 Output: 2^2 3^1 Input: 100 Output: 2^2 5^2 The cauldron bubbles faster now. The kingdom's mathematicians are watching, and the vault door trembles. Break the number into its primal essence, and the treasure of Prime City shall be yours.
Constraints:
2 <= N <= 10^12
Tags:
