Search code examples
c++calgorithmfactors

All factors of big numbers in C/C++


I am trying to find out all factors of numbers which are of the order of 10^18... But there are time constraints which are creating a problem. What i did was to use Sieve of Eratosthenes to find factors and then store the factors but it is slow.......


Solution

  • If space is not a problem, you could store a list of prime numbers up to 10^9 (lists are available for download) and use it to factorize any number up to 10^18. You could also use factoring algorithms (like pollard's rho, or others).