Hubbry Logo
Integer factorizationInteger factorizationMain
Open search
Integer factorization
Community hub
Integer factorization
logo
7 pages, 0 posts
0 subscribers
Be the first to start a discussion here.
Be the first to start a discussion here.
Integer factorization
Integer factorization
from Wikipedia
Unsolved problem in computer science
Can integer factorization be solved in polynomial time on a classical computer?

In mathematics, 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 greater than 1, in which case it is a composite number, or it is not, in which case it is 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 pen-and-paper 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 non-quantum 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 public-key encryption and the RSA digital signature.[1] Many areas of mathematics and computer science have been brought to bear on this 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 classical 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 classical computer increases drastically.

Many cryptographic protocols are based on the presumed 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 RSA-based public-key cryptography insecure.

Prime decomposition

[edit]
Prime decomposition of n = 864 as 25 × 33

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 special-purpose 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 = a2n = 4 = 2 and hence the factors ab = 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

[edit]

Among the b-bit 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, a 240-digit (795-bit) number (RSA-240) was factored by a team of researchers including Paul Zimmermann, utilizing approximately 900 core-years of computing power.[2] These researchers estimated that a 1024-bit RSA modulus would take about 500 times as long.[3]

The largest such semiprime yet factored was RSA-250, an 829-bit number with 250 decimal digits, in February 2020. The total computation time was roughly 2700 core-years 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.

Time complexity

[edit]

No algorithm has been published that can factor all integers in polynomial time, that is, that can factor a b-bit number n in time O(bk) for some constant k. Neither the existence nor non-existence of such algorithms has been proved, but it is generally suspected that they do not exist.[4][5]

There are published algorithms that are faster than O((1 + ε)b) for all positive ε, that is, sub-exponential. As of 2022, the algorithm with best theoretical asymptotic running time is the general number field sieve (GNFS), first published in 1993,[6] running on a b-bit number n in time:

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. Shor's algorithm takes only O(b3) time and O(b) space on b-bit number inputs. In 2001, Shor's algorithm was implemented for the first time, by using NMR techniques on molecules that provide seven qubits.[7]

In order to talk about complexity classes such as P, NP, and co-NP, the problem has to be stated as a decision problem.

Decision problem (Integer factorization)For every natural numbers and , does n have a factor smaller than k besides 1?

It is known to be in both NP and co-NP, 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 dk. 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 co-UP.[8] 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, NP-complete,[9] and co-NP-complete. It is therefore a candidate for the NP-intermediate complexity class.

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

[edit]

Special-purpose

[edit]

A special-purpose 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 special-purpose 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 general-purpose methods to remove small factors.[10] For example, naive trial division is a Category 1 algorithm.

General-purpose

[edit]

A general-purpose 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 general-purpose factoring algorithms are based on the congruence of squares method.

Other notable algorithms

[edit]

Heuristic running time

[edit]

In number theory, there are many integer factoring algorithms that heuristically have expected running time

in little-o and L-notation. 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.

Rigorous running time

[edit]

The Schnorr–Seysen–Lenstra probabilistic algorithm has been rigorously proven by Lenstra and Pomerance[14] to have expected running time Ln[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

[edit]

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 fq of GΔ with q in PΔ a sequence of relations between the set of generators and fq are produced. The size of q can be bounded by c0(log|Δ|)2 for some constant c0.

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 so-called 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.

  1. Let Δ be a negative integer with Δ = −dn, where d is a multiplier and Δ is the negative discriminant of some quadratic form.
  2. Take the t first primes p1 = 2, p2 = 3, p3 = 5, ..., pt, for some tN.
  3. Let fq be a random prime form of GΔ with (Δ/q) = 1.
  4. Find a generating set X of GΔ.
  5. Collect a sequence of relations between set X and {fq : qPΔ} satisfying:
  6. Construct an ambiguous form (a, b, c) that is an element fGΔ 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).
  7. 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 2-Sylow group Sll2(Δ) 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

[edit]

The algorithm as stated is a probabilistic algorithm as it makes random choices. Its expected running time is at most Ln[1/2, 1+o(1)].[14]

See also

[edit]

Notes

[edit]

References

[edit]
[edit]
Revisions and contributorsEdit on WikipediaRead on Wikipedia
from Grokipedia
Integer factorization is the process of decomposing a positive integer (specifically, a composite number) into a product of smaller positive integers, ideally prime numbers, known as its prime factors. This problem is a cornerstone of number theory, with practical significance in areas such as computational complexity and cryptography, where the difficulty of factoring large semiprimes—products of two large primes—forms the security basis for public-key cryptosystems like RSA. While small integers can be factored efficiently using basic methods like trial division, which systematically tests divisors up to the square root of the number, larger composites require more sophisticated algorithms. Notable classical algorithms include Pollard's rho method for finding small factors, the quadratic sieve for general-purpose factoring, and the general number field sieve (GNFS), the fastest known classical approach for very large numbers, with subexponential time complexity. In the quantum computing domain, Shor's algorithm provides a polynomial-time solution to factorization, leveraging quantum Fourier transforms to solve the period-finding problem, thereby threatening the long-term viability of factorization-based encryption. Despite advances, factoring record-breaking semiprimes remains resource-intensive; as of 2025, the largest RSA challenge number factored classically was RSA-250 (829 bits), underscoring the ongoing computational challenge.

Fundamentals

Definition and Motivation

Integer factorization refers to the decomposition of a composite positive integer n>1n > 1 into its prime factors, expressing nn as a product of prime numbers. This process involves identifying the primes p1,p2,,pkp_1, p_2, \dots, p_k such that n=p1e1p2e2pkekn = p_1^{e_1} p_2^{e_2} \cdots p_k^{e_k}, where each ei1e_i \geq 1. The problem appears deceptively simple for small values of nn; for instance, factoring 15 yields 15=3×515 = 3 \times 5, which can be verified by basic division. However, as nn grows large—particularly when nn is a product of two large primes—the computational effort required escalates dramatically, making it infeasible with current classical methods for sufficiently large instances. An illustrative example is 91, which factors as 91=7×1391 = 7 \times 13, but scaling this to hundreds of digits reveals the inherent challenge. Historically, interest in factorization arose in number theory from ancient efforts to understand prime numbers and their properties, as explored by Euclid in his Elements around 300 BCE, where he laid foundational work on divisibility and primes. Euclid's propositions, such as those demonstrating the infinitude of primes and the structure of integers, motivated early studies in factorization as a means to explore the building blocks of natural numbers. In modern computing, factorization's significance stems from its role as a computationally hard problem underpinning public-key cryptography, notably the RSA cryptosystem introduced in 1978, whose security depends on the difficulty of factoring large semiprimes. This hardness ensures that encrypted messages remain secure against adversaries lacking efficient factoring capabilities, driving ongoing research in both theoretical mathematics and practical algorithms. The uniqueness of such decompositions is affirmed by the fundamental theorem of arithmetic.

Prime Factorization Theorem

The Fundamental Theorem of Arithmetic, also known as the unique factorization theorem, asserts that every integer greater than 1 can be expressed as a product of one or more prime numbers, and this representation is unique up to the order of the factors. Formally, for any integer n>1n > 1, there exist prime numbers p1,p2,,pkp_1, p_2, \dots, p_k (not necessarily distinct) such that n=p1p2pkn = p_1 p_2 \cdots p_k, and if n=q1q2qmn = q_1 q_2 \cdots q_m is another such factorization with primes qjq_j, then k=mk = m and the multisets {p1,,pk}\{p_1, \dots, p_k\} and {q1,,qm}\{q_1, \dots, q_m\} are identical. The proof proceeds in two parts: establishing existence and proving uniqueness. For existence, the well-ordering principle of the natural numbers is invoked. Suppose there exists some integer greater than 1 without a prime factorization; among all such integers, let nn be the smallest. Then nn cannot be prime (as primes factorize trivially as themselves), so n=abn = ab with 1<a,b<n1 < a, b < n. By minimality, aa and bb have prime factorizations, hence so does nn, a contradiction. Thus, every integer greater than 1 has at least one prime factorization. Uniqueness relies on Euclid's lemma, which states that if a prime pp divides a product abab, then pp divides aa or pp divides bb. To prove Euclid's lemma, assume pabp \mid ab but pap \nmid a; then gcd(p,a)=1\gcd(p, a) = 1, so there exist integers x,yx, y such that px+ay=1px + ay = 1 by Bézout's identity. Multiplying by bb yields p(xb)+a(by)=bp(xb) + a(by) = b, and since pabp \mid ab, it follows that pbp \mid b. With Euclid's lemma, uniqueness follows by contradiction: suppose two distinct factorizations n=p1e1prer=q1f1qsfsn = p_1^{e_1} \cdots p_r^{e_r} = q_1^{f_1} \cdots q_s^{f_s}; then some prime, say p1p_1, must divide the right side, hence divide some qjq_j, implying p1=qjp_1 = q_j, and inducting on the exponents shows all match. For example, the integer 12 factors as 12=22×312 = 2^2 \times 3, and this is the unique prime factorization, as any other decomposition (e.g., 12=4×3=22×312 = 4 \times 3 = 2^2 \times 3) reduces to the same primes with identical multiplicities. This theorem underscores the multiplicative structure of the integers, ensuring that arithmetic operations like greatest common divisors and least common multiples can be computed via prime exponents, and it forms the basis for much of elementary number theory, such as the distribution of primes and properties of integers under multiplication. While the theorem holds specifically for the ring of integers Z\mathbb{Z}, where primes are irreducible and lead to unique factorization, other integral domains like the Gaussian integers Z\mathbb{Z} also exhibit unique factorization into irreducibles (Gaussian primes), though the notion of primality differs— for instance, 2 factors as (1+i)(1i)(1+i)(1-i) up to units. However, not all rings share this property; the focus here remains on Z\mathbb{Z}, where the theorem guarantees irreducibility aligns perfectly with primality.

Classical Algorithms

Trial Division and Basic Methods

Trial division is one of the simplest and most straightforward methods for factoring an integer n>1n > 1. It involves systematically testing for divisibility by all integers starting from 2 up to n\sqrt{n}
Add your contribution
Related Hubs
User Avatar
No comments yet.