Integer factorization
Unsolved problem in computer science: Can integer factorization be solved in polynomial time on a classical computer? (more unsolved problems in computer science)

In number theory, integer factorization is the decomposition of a positive integer into a product of integers. Every positive integer greater than 1 is either the product of two or more integer factors, in which case it is called a composite number, or it is not, in which case it is called a prime number. For example, 15 is a composite number because 15 = 3 · 5, but 7 is a prime number because it cannot be decomposed in this way. If one of the factors is composite, it can in turn be written as a product of smaller factors, for example 60 = 3 · 20 = 3 · (5 · 4). Continuing this process until every factor is prime is called prime factorization; the result is always unique up to the order of the factors by the prime factorization theorem.
To factorize a small integer n using mental or penandpaper arithmetic, the simplest method is trial division: checking if the number is divisible by prime numbers 2, 3, 5, and so on, up to the square root of n. For larger numbers, especially when using a computer, various more sophisticated factorization algorithms are more efficient. A prime factorization algorithm typically involves testing whether each factor is prime each time a factor is found.
When the numbers are sufficiently large, no efficient nonquantum integer factorization algorithm is known. However, it has not been proven that such an algorithm does not exist. The presumed difficulty of this problem is important for the algorithms used in cryptography such as RSA publickey encryption and the RSA digital signature.^{[1]} Many areas of mathematics and computer science have been brought to bear on the problem, including elliptic curves, algebraic number theory, and quantum computing.
Not all numbers of a given length are equally hard to factor. The hardest instances of these problems (for currently known techniques) are semiprimes, the product of two prime numbers. When they are both large, for instance more than two thousand bits long, randomly chosen, and about the same size (but not too close, for example, to avoid efficient factorization by Fermat's factorization method), even the fastest prime factorization algorithms on the fastest computers can take enough time to make the search impractical; that is, as the number of digits of the integer being factored increases, the number of operations required to perform the factorization on any computer increases drastically.
Many cryptographic protocols are based on the difficulty of factoring large composite integers or a related problem—for example, the RSA problem. An algorithm that efficiently factors an arbitrary integer would render RSAbased publickey cryptography insecure.
Prime decomposition
By the fundamental theorem of arithmetic, every positive integer has a unique prime factorization. (By convention, 1 is the empty product.) Testing whether the integer is prime can be done in polynomial time, for example, by the AKS primality test. If composite, however, the polynomial time tests give no insight into how to obtain the factors.
Given a general algorithm for integer factorization, any integer can be factored into its constituent prime factors by repeated application of this algorithm. The situation is more complicated with specialpurpose factorization algorithms, whose benefits may not be realized as well or even at all with the factors produced during decomposition. For example, if n = 171 × p × q where p < q are very large primes, trial division will quickly produce the factors 3 and 19 but will take p divisions to find the next factor. As a contrasting example, if n is the product of the primes 13729, 1372933, and 18848997161, where 13729 × 1372933 = 18848997157, Fermat's factorization method will begin with ⌈√n⌉ = 18848997159 which immediately yields b = √a^{2} − n = √4 = 2 and hence the factors a − b = 18848997157 and a + b = 18848997161. While these are easily recognized as composite and prime respectively, Fermat's method will take much longer to factor the composite number because the starting value of ⌈√18848997157⌉ = 137292 for a is a factor of 10 from 1372933.
Current state of the art
Among the bbit numbers, the most difficult to factor in practice using existing algorithms are those semiprimes whose factors are of similar size. For this reason, these are the integers used in cryptographic applications.
In 2019, Fabrice Boudot, Pierrick Gaudry, Aurore Guillevic, Nadia Heninger, Emmanuel Thomé and Paul Zimmermann factored a 240digit (795bit) number (RSA240) utilizing approximately 900 coreyears of computing power.^{[2]} The researchers estimated that a 1024bit RSA modulus would take about 500 times as long.^{[3]}
The largest such semiprime yet factored was RSA250, an 829bit number with 250 decimal digits, in February 2020. The total computation time was roughly 2700 coreyears of computing using Intel Xeon Gold 6130 at 2.1 GHz. Like all recent factorization records, this factorization was completed with a highly optimized implementation of the general number field sieve run on hundreds of machines.
Difficulty and complexity
No algorithm has been published that can factor all integers in polynomial time, that is, that can factor a bbit number n in time O(b^{k}) for some constant k. Neither the existence nor nonexistence of such algorithms has been proved, but it is generally suspected that they do not exist and hence that the problem is not in class P.^{[4]}^{[5]} The problem is clearly in class NP, but it is generally suspected that it is not NPcomplete, though this has not been proven.^{[6]}
There are published algorithms that are faster than O((1 + ε)^{b}) for all positive ε, that is, subexponential. (As of 2022), the algorithm with best theoretical asymptotic running time is the general number field sieve (GNFS), first published in 1993,^{[7]} running on a bbit number n in time:
 [math]\displaystyle{ \exp\left( \left(\left(\tfrac83\right)^\frac23 + o(1)\right)\left(\log n\right)^\frac13\left(\log \log n\right)^\frac23\right). }[/math]
For current computers, GNFS is the best published algorithm for large n (more than about 400 bits). For a quantum computer, however, Peter Shor discovered an algorithm in 1994 that solves it in polynomial time. This will have significant implications for cryptography if quantum computation becomes scalable. Shor's algorithm takes only O(b^{3}) time and O(b) space on bbit number inputs. In 2001, Shor's algorithm was implemented for the first time, by using NMR techniques on molecules that provide seven qubits.^{[8]}
It is not known exactly which complexity classes contain the decision version of the integer factorization problem (that is: does n have a factor smaller than k besides 1?). It is known to be in both NP and coNP, meaning that both "yes" and "no" answers can be verified in polynomial time. An answer of "yes" can be certified by exhibiting a factorization n = d(n/d) with d ≤ k. An answer of "no" can be certified by exhibiting the factorization of n into distinct primes, all larger than k; one can verify their primality using the AKS primality test, and then multiply them to obtain n. The fundamental theorem of arithmetic guarantees that there is only one possible string of increasing primes that will be accepted, which shows that the problem is in both UP and coUP.^{[9]} It is known to be in BQP because of Shor's algorithm.
The problem is suspected to be outside all three of the complexity classes P, NPcomplete, and coNPcomplete. It is therefore a candidate for the NPintermediate complexity class. If it could be proved to be either NPcomplete or coNPcomplete, this would imply NP = coNP, a very surprising result, and therefore integer factorization is widely suspected to be outside both these classes.
In contrast, the decision problem "Is n a composite number?" (or equivalently: "Is n a prime number?") appears to be much easier than the problem of specifying factors of n. The composite/prime problem can be solved in polynomial time (in the number b of digits of n) with the AKS primality test. In addition, there are several probabilistic algorithms that can test primality very quickly in practice if one is willing to accept a vanishingly small possibility of error. The ease of primality testing is a crucial part of the RSA algorithm, as it is necessary to find large prime numbers to start with.
Factoring algorithms
Specialpurpose
A specialpurpose factoring algorithm's running time depends on the properties of the number to be factored or on one of its unknown factors: size, special form, etc. The parameters which determine the running time vary among algorithms.
An important subclass of specialpurpose factoring algorithms is the Category 1 or First Category algorithms, whose running time depends on the size of smallest prime factor. Given an integer of unknown form, these methods are usually applied before generalpurpose methods to remove small factors.^{[10]} For example, naive trial division is a Category 1 algorithm.
 Trial division
 Wheel factorization
 Pollard's rho algorithm, which has two common flavors to identify group cycles: one by Floyd and one by Brent.
 Algebraicgroup factorization algorithms, among which are Pollard's p − 1 algorithm, Williams' p + 1 algorithm, and Lenstra elliptic curve factorization
 Fermat's factorization method
 Euler's factorization method
 Special number field sieve
 Difference of two squares
Generalpurpose
A generalpurpose factoring algorithm, also known as a Category 2, Second Category, or Kraitchik family algorithm,^{[10]} has a running time which depends solely on the size of the integer to be factored. This is the type of algorithm used to factor RSA numbers. Most generalpurpose factoring algorithms are based on the congruence of squares method.
 Dixon's factorization method
 Continued fraction factorization (CFRAC)
 Quadratic sieve
 Rational sieve
 General number field sieve
 Shanks's square forms factorization (SQUFOF)
Other notable algorithms
 Shor's algorithm, for quantum computers
Heuristic running time
In number theory, there are many integer factoring algorithms that heuristically have expected running time
 [math]\displaystyle{ L_n\left[\tfrac12,1+o(1)\right]=e^{(1+o(1))\sqrt{(\log n)(\log \log n)}} }[/math]
in littleo and Lnotation. Some examples of those algorithms are the elliptic curve method and the quadratic sieve. Another such algorithm is the class group relations method proposed by Schnorr,^{[11]} Seysen,^{[12]} and Lenstra,^{[13]} which they proved only assuming the unproved Generalized Riemann Hypothesis (GRH).
Rigorous running time
The Schnorr–Seysen–Lenstra probabilistic algorithm has been rigorously proven by Lenstra and Pomerance^{[14]} to have expected running time L_{n}[1/2, 1+o(1)] by replacing the GRH assumption with the use of multipliers. The algorithm uses the class group of positive binary quadratic forms of discriminant Δ denoted by G_{Δ}. G_{Δ} is the set of triples of integers (a, b, c) in which those integers are relative prime.
Schnorr–Seysen–Lenstra algorithm
Given an integer n that will be factored, where n is an odd positive integer greater than a certain constant. In this factoring algorithm the discriminant Δ is chosen as a multiple of n, Δ = −dn, where d is some positive multiplier. The algorithm expects that for one d there exist enough smooth forms in G_{Δ}. Lenstra and Pomerance show that the choice of d can be restricted to a small set to guarantee the smoothness result.
Denote by P_{Δ} the set of all primes q with Kronecker symbol (Δ/q) = 1. By constructing a set of generators of G_{Δ} and prime forms f_{q} of G_{Δ} with q in P_{Δ} a sequence of relations between the set of generators and f_{q} are produced. The size of q can be bounded by c_{0}(logΔ)^{2} for some constant c_{0}.
The relation that will be used is a relation between the product of powers that is equal to the neutral element of G_{Δ}. These relations will be used to construct a socalled ambiguous form of G_{Δ}, which is an element of G_{Δ} of order dividing 2. By calculating the corresponding factorization of Δ and by taking a gcd, this ambiguous form provides the complete prime factorization of n. This algorithm has these main steps:
Let n be the number to be factored.
 Let Δ be a negative integer with Δ = −dn, where d is a multiplier and Δ is the negative discriminant of some quadratic form.
 Take the t first primes p_{1} = 2, p_{2} = 3, p_{3} = 5, ..., p_{t}, for some t ∈ N.
 Let f_{q} be a random prime form of G_{Δ} with (Δ/q) = 1.
 Find a generating set X of G_{Δ}.
 Collect a sequence of relations between set X and {f_{q} : q ∈ P_{Δ}} satisfying:
 [math]\displaystyle{ \left(\prod_{x \in X_{}} x^{r(x)}\right).\left(\prod_{q \in P_\Delta} f^{t(q)}_{q}\right) = 1. }[/math]
 Construct an ambiguous form (a, b, c) that is an element f ∈ G_{Δ} of order dividing 2 to obtain a coprime factorization of the largest odd divisor of Δ in which Δ = −4ac or Δ = a(a − 4c) or Δ = (b − 2a)(b + 2a).
 If the ambiguous form provides a factorization of n then stop, otherwise find another ambiguous form until the factorization of n is found. In order to prevent useless ambiguous forms from generating, build up the 2Sylow group Sll_{2}(Δ) of G(Δ).
To obtain an algorithm for factoring any positive integer, it is necessary to add a few steps to this algorithm such as trial division, and the Jacobi sum test.
Expected running time
The algorithm as stated is a probabilistic algorithm as it makes random choices. Its expected running time is at most L_{n}[1/2, 1+o(1)].^{[14]}
See also
 Aurifeuillean factorization
 Bach's algorithm for generating random numbers with their factorizations
 Canonical representation of a positive integer
 Factorization
 Multiplicative partition
 padic valuation
 Partition (number theory) – a way of writing a number as a sum of positive integers.
Notes
 ↑ Lenstra, Arjen K. (2011), van Tilborg, Henk C. A.; Jajodia, Sushil, eds. (in en), Integer Factoring, Boston, MA: Springer US, pp. 611–618, doi:10.1007/9781441959065_455, ISBN 9781441959058, http://link.springer.com/10.1007/9781441959065_455, retrieved 20220622
 ↑ "[Cadonfsdiscuss 795bit factoring and discrete logarithms"]. https://lists.gforge.inria.fr/pipermail/cadonfsdiscuss/2019December/001139.html.
 ↑ Kleinjung (20100218). Factorization of a 768bit RSA modulus. International Association for Cryptologic Research. http://eprint.iacr.org/2010/006.pdf. Retrieved 20100809.
 ↑ Krantz, Steven G. (2011), The Proof is in the Pudding: The Changing Nature of Mathematical Proof, New York: Springer, p. 203, doi:10.1007/9780387487441, ISBN 9780387489087, https://books.google.com/books?id=mMZBtxVZiQoC&pg=PA203
 ↑ Arora, Sanjeev; Barak, Boaz (2009), Computational complexity, Cambridge: Cambridge University Press, p. 230, doi:10.1017/CBO9780511804090, ISBN 9780521424264, https://books.google.com/books?id=nGvI7cOuOOQC&pg=PA230
 ↑ Goldreich, Oded; Wigderson, Avi (2008), "IV.20 Computational Complexity", in Gowers, Timothy; BarrowGreen, June; Leader, Imre, The Princeton Companion to Mathematics, Princeton, New Jersey: Princeton University Press, pp. 575–604, ISBN 9780691118802. See in particular p. 583.
 ↑ Buhler, J. P.; Lenstra, H. W. Jr.; Pomerance, Carl (1993). "Factoring integers with the number field sieve" (in English). The development of the number field sieve. Lecture Notes in Mathematics. 1554. Springer. pp. 50–94. doi:10.1007/BFb0091539. ISBN 9783540570134. https://doi.org/10.1007/BFb0091539. Retrieved 12 March 2021.
 ↑ Vandersypen, Lieven M. K. (2001). "Experimental realization of Shor's quantum factoring algorithm using nuclear magnetic resonance". Nature 414 (6866): 883–887. doi:10.1038/414883a. PMID 11780055. Bibcode: 2001Natur.414..883V.
 ↑ Lance Fortnow (20020913). "Computational Complexity Blog: Complexity Class of the Week: Factoring". http://weblog.fortnow.com/2002/09/complexityclassofweekfactoring.html.
 ↑ ^{10.0} ^{10.1} David Bressoud and Stan Wagon (2000). A Course in Computational Number Theory. Key College Publishing/Springer. pp. 168–69. ISBN 9781930190108. https://archive.org/details/courseincomputat0000bres/page/168.
 ↑ Schnorr, Claus P. (1982). "Refined analysis and improvements on some factoring algorithms". Journal of Algorithms 3 (2): 101–127. doi:10.1016/01966774(82)900128. http://www.dtic.mil/gettrdoc/pdf?AD=ADA096348.
 ↑ Seysen, Martin (1987). "A probabilistic factorization algorithm with quadratic forms of negative discriminant". Mathematics of Computation 48 (178): 757–780. doi:10.1090/S0025571819870878705X.
 ↑ Lenstra, Arjen K (1988). "Fast and rigorous factorization under the generalized Riemann hypothesis". Indagationes Mathematicae 50 (4): 443–454. doi:10.1016/S13857258(88)800222. https://infoscience.epfl.ch/record/164491/files/nscan9.PDF.
 ↑ ^{14.0} ^{14.1} Lenstra, H. W.; Pomerance, Carl (July 1992). "A Rigorous Time Bound for Factoring Integers". Journal of the American Mathematical Society 5 (3): 483–516. doi:10.1090/S08940347199211371000. https://www.ams.org/journals/jams/19920503/S08940347199211371000/S08940347199211371000.pdf.
References
 Richard Crandall and Carl Pomerance (2001). Prime Numbers: A Computational Perspective. Springer. ISBN 0387947779. Chapter 5: Exponential Factoring Algorithms, pp. 191–226. Chapter 6: Subexponential Factoring Algorithms, pp. 227–284. Section 7.4: Elliptic curve method, pp. 301–313.
 Donald Knuth. The Art of Computer Programming, Volume 2: Seminumerical Algorithms, Third Edition. AddisonWesley, 1997. ISBN:0201896842. Section 4.5.4: Factoring into Primes, pp. 379–417.
 Samuel S. Wagstaff Jr. (2013). The Joy of Factoring. Providence, RI: American Mathematical Society. ISBN 9781470410483. https://www.ams.org/bookpages/stml68..
 Warren, Henry S. Jr. (2013). Hacker's Delight (2 ed.). Addison Wesley  Pearson Education, Inc.. ISBN 9780321842688.
External links
 msieve – SIQS and NFS – has helped complete some of the largest public factorizations known
 Richard P. Brent, "Recent Progress and Prospects for Integer Factorisation Algorithms", Computing and Combinatorics", 2000, pp. 3–22. download
 Manindra Agrawal, Neeraj Kayal, Nitin Saxena, "PRIMES is in P." Annals of Mathematics 160(2): 781–793 (2004). August 2005 version PDF
 Eric W. Weisstein, “RSA640 Factored” MathWorld Headline News, November 8, 2005
 Dario Alpern's Integer factorization calculator – A web app for factoring large integers
Original source: https://en.wikipedia.org/wiki/Integer factorization.
Read more 