How do I find prime factorization of numbers that are very large (up to $\mathbf{10^{12}}$).
Actually I need powers of the primes that we get after prime factorization of a number.
I cant use the Sieve of Eratosthenes because of its space complexity.
Please suggest me a way to do this!
Actually I need to find prime factorization of all numbers in a range and that range contains at max 105 elements.
Note from Comments: The OP is motivated by an exercise in which, for each $n$ in a range of size $10^5$, the divisor of $n$ with the largest number of divisors is selected, and then its divisor with the largest number of divisors is selected, etc. until $1$ is reached. The number of divisors of these selected numbers is totaled. [A couple of points are unclear: is the total to be found over the entire range, or reported as a sum for each $n$ in the range? Is the number of divisors of $n$ to be included in such sums? It would help if the OP included a link to the original problem statement, but it is clear why a prime factorization of each $n$ will allow the divisor count to be quickly computed.]
I assume you're aware that factoring large integers is not a trivial computational operation. Any technique will involve some kind of search or sieve.
In your case, notice that you only need to look for primes up to $10^6$, which is feasible by precomputing or downloading a table of primes and then performing trial division.