Abstract
The integer factorization problem is a hard problem in classical. Let , where P and Q are large primes. Pollard’s P-1 Algorithm is an efficient integer factorization algorithm while all the prime factors of are small. However, the previous variants of Pollard’s P-1 algorithms require a strict bound on the prime factors, and the running time depends on the bound instead of the actual size of prime factors, which is undesirable. This paper firstly designs a dynamic scaling version of Pollard’s P-1 Algorithm (abbreviate as ) to solve this problem and also accelerate the algorithm’s efficiency by applying a fast multiplication method to it. Additionally, saves the cost in computing the product of prime factors with high enough exponent by repeatedly using product of primes with low exponent. We also give the complexity analysis for our proposed algorithm and the latest published variant of Pollard’s P-1 Algorithm named IPP1 (Kritsanapong Somsuk, Symmetry). Moreover, we give a theoretical comparison between IPP1 and our algorithm. In particular, we show that our algorithm costs less than IPP1 in more than 95% while in IPP1 the bound of prime factors of P-1 is set to at least 64. Additionally, we also test several instances in factoring 1024-bit integers in experiment. We firstly construct the as a product of several randomly generated 30-bit numbers to ensure its solvability by the Pollard’s P-1 Algorithm, then test four variants of Pollard’s P-1 Algorithm. The experimental result shows that our algorithm is most efficient among them. Its efficiency improvement performs more apparently while the exponent of a prime factor in is large. In factoring 1024-bit integer, our algorithm solves it nearly 23.5 times faster than IPP1, 16.4 times faster than the Original Pollard’s P-1 Algorithm (J. M. Pollard, MPCPS), 35.6 times faster than the trivial Pollard’s P-1 Algorithm (D. Bishop, Introduction to cryptography with Java applets).
1. Introduction
The security of RSA [1] relies heavily on the computational difficulty of integer factorization. While general-purpose algorithms like the number field sieve (NFS) [2] exist, special-purpose methods are often more efficient for specific moduli. Notably, when a prime factor P of the RSA modulus has a “smooth” (i.e., consisting entirely of small prime factors), Pollard’s P-1 algorithm [3] is frequently employed. Based on Fermat’s Little Theorem [4] (i.e., ), the algorithm iteratively evaluates for a chosen base a (e.g., ), where the exponent z is constructed from all small primes up to a predefined smoothness bound B. If z is a multiple of , we have , thereby factoring N. However, its running time depends entirely on the largest prime factor of , reaching a worst-case complexity of .
Several variants have attempted to optimize this process. A trivial version proposed by Bishop [5] iteratively tests exponent factorials (i.e., let for an increasing integer x). While effective in theory, evaluating heavily over-computes the necessary prime powers, resulting in massive inefficiency. More recently, Somsuk [6] proposed , which first computes the product of all primes up to a smoothness bound B (i.e., ) and performs modular exponentiation up to , where is a given upper bound on the exponents. However, becomes highly inefficient if even a single prime factor of possesses a large exponent. Furthermore, both the original algorithm and require a predefined smoothness bound B. Choosing an optimal B beforehand is practically difficult: an overly small B guarantees failure, while an overly large B wastes significant computational time.
1.1. Our Contributions
To overcome the limitations of prior methods, this paper proposes novel algorithmic improvements. The remainder of the paper is organized to detail these contributions as follows. Section 2 introduces the basic notations and preliminaries. In Section 3, we present our primary contribution, the Dynamic Scaling Pollard’s P-1 algorithm () (Section 3.1). By employing a dynamic traversal order, systematically enumerates prime factors and their exponents without relying on a predetermined smoothness bound. This progressive scaling and continuous reuse of prior prime products drastically reduce redundant modular exponentiations while ensuring full coverage of potential prime factors. This section subsequently provides formal cost estimators and theoretical complexity analyses for both and (Section 3.3). Furthermore, to efficiently evaluate the massive prime products required during execution, Section 4.1 introduces a novel Fast Multiplication (FM) method. We provide theoretical cost estimators and complexity analyses for both FM and the normal multiplication (NM) method (Section 4.2). A comprehensive theoretical and experimental comparison (Section 4.3) confirms the necessity of FM, demonstrating that NM incurs a time overhead times higher than our FM approach. To substantiate our approach, Section 5 conducts a detailed theoretical cost analysis and an empirical experimental comparison among four implemented variants of Pollard’s P-1 algorithm. We provide a comprehensive complexity analysis proving that achieves strictly lower computational costs than the state-of-the-art algorithm in over 95% of cases (provided ). We implemented and evaluated alongside three prior variants on 1024-bit moduli (https://github.com/Summwer/expemeriment_of_pollardpm1, accessed on 1 August 2026). The experimental results robustly validate our theoretical estimators and highlight ’s superiority when prime factors have high exponents (see Figure 1). Specifically, operates 23.5×, 16.4×, and 35.6× faster than [6], the original algorithm [3], and the trivial variant [5], respectively.
Figure 1.
Complexity comparison between our variant and IPP1 while where , P and Q are both primes. The x-axis is and the y-axis is the cost in cycles. The green triangle is cost of our variant in experiment. The blue circle is the cost of IPP1 in experiment. The yellow triangle is the estimated cost of our variant generated by estimator. The red circle is the estimated cost of IPP1 generated by estimator. The dash line is the theoretical cost of our variant computed by Theorem 2. The dot-and-dash line is the theoretical cost of our variant computed by Theorem 1.
1.2. Technical Overview
1.2.1. Dynamic Scaling Pollards P-1 Algorithm
(Algorithm 4) dynamically constructs the target exponent by partitioning prime candidates into disjoint intervals . For (initialized with ), it computes and recursively generates the exponent , updating . This yields , efficiently raising smaller primes to exponentially growing powers. By computing , minimizes redundant modular exponentiations through the systematic reuse of earlier products. For the final subset , where any prime exponent is at most 1, bypasses deep recursion and finishes purely via shift modular exponentiation.
1.2.2. Fast Multiplication (FM)
Furthermore, to efficiently evaluate massive products without introducing intolerable computational bottlenecks, we integrate our FM method. Let be an ascending list of integers defined in Section 2. Unlike NM, which computes the product linearly and accumulates unbalanced bit-lengths, FM employs a symmetric divide-and-conquer strategy. In each iteration, FM generates a new, halved sequence by pairing and multiplying elements from opposite ends, i.e., Repeat until only a single element remains. FM ensures that intermediate 1556 products maintain strictly balanced bit-lengths at each depth of the multiplication tree. This hierarchical reduction drastically minimizes the overall asymptotic bit-complexity.
2. Preliminaries
2.1. Notations and Basic Definitions
Let denote the set of integers. For a positive integer Y, we denote the reduction of by (i.e., ). Let be an RSA modulus, where P and Q are two large distinct primes. Denote as the bit-length of the modulus N. Recovering P and Q given N is known as the Integer Factorization Problem(). To ensure the hardness of the in cryptographic applications, P and Q are typically required to be of approximately equal bit-length. Under this condition, when P and Q are sufficiently large, no classical polynomial-time algorithm is currently known to solve the . Let denote Euler’s totient function. To facilitate our subsequent complexity analysis, we recall the Prime Number Theorem [7]: the prime-counting function , which denotes the number of primes less than or equal to x, satisfies .
Although the is generally hard, special-purpose factoring algorithms (such as Pollard’s P-1) can efficiently factor N if the prime factors possess specific algebraic weaknesses. The most prominent weakness exploited by these algorithms is the smoothness of . Formally, this property is defined as follows:
Definition 1
(B-Smooth Number). A B-smooth number is a positive integer whose prime factors are all less than or equal to B.
Following standard cryptographic settings, we assume the prime factors P and Q have a balanced bit-length . Let . To ensure that the prime Q is strictly resistant to our algorithm, we assume that the largest prime factor of strictly exceeds .
To formally characterize the vulnerability of the prime factor P, we first consider its odd part , since is inherently even. Let denote the k-th prime number globally. Let be the input smoothness bound (which defaults to the theoretical maximum ). We define as the complete list of consecutive primes up to , where denotes the k-th prime globally. Assuming is -smooth, we let denote the actual exponent of any prime candidate in its factorization. We can express this prime factorization compactly as . Here, denotes the actual exponent of the prime factor , and the indices satisfy (where ). Define as the explicit upper bound of this exponent, computed as . Since , this naturally guarantees . Define the maximum actual exponent as , and the largest prime power factor as , where is the index achieving this maximum. For any positive integer z, let denote its bit-length. For each prime , let denote its specific bit-length. Finally, to align with our dynamic scaling strategy, we partition into disjoint subsets, explicitly bounded by , denoted as for . Let be an ascending list of integers where each element is selected independently with probability . For brevity, we denote this list as L, and define .
Lemma 1.
The expected structural bit-size of the product of all elements in is
If , we can obtain that .
Proof.
Let be the indicator variable for , with expectation . In practical arbitrary-precision arithmetic, the upper bound of the bit-size of a product is exactly the sum of the discrete bit-lengths of all operands. For any integer , its exact bit-length is k.
Given that the elements in list L are bounded in the range , this range can be partitioned into subsets of exactly k-bit integers for . The amount of k-bit positive integers in each subset is .
By linearity of expectation, the expected total structural bit-length is:
Using the arithmetico-geometric sequence summation formula , we evaluate the bounded sum:
Substituting this back yields . □
Having established the expected bit-size of the prime products, we proceed to analyze the cumulative computational overhead of our dynamic strategy across multiple iterations. If we model the scale of the operand at the i-th iteration as a linear progression , evaluating the total cost inherently involves summations of the form . By approximating this discrete summation with continuous integration, we deduce the following asymptotic bound:
Lemma 2.
Proof.
.
□
2.2. Complexity Analysis of Basic Operations
The size of inputting integers will affect the complexity of basic operations while the integer is large. Thus, we list the complexity of basic operations in this Section for further complexity analysis of Pollard’s P-1 Algorithm and its variances. We will introduce complexity of multiplication, modular powering, normal powering and the greatest common divisor as four basic operations used in Pollard’s P-1 Algorithm in the following part.
2.2.1. Complexity of Multiplication
There are seven multiplication algorithms at current for implementing multiplication operation: Basecase, Karatsuba, Toom-3, Toom-4 and FFT algorithm. Let n and m be the sizes of two multipliers, where . Ref. [8] shows that it costs by Basecase Algorithm (Section 4.3.1 Algorithm M in [8]). It also introduces that Karatsuba is asymptotically an algorithm (Section 4.3.3 part A in [8]). A description of Toom can be found in Section 4.3.3 in [8], it takes for Toom-3 and for Toom-4. For large integer multiplication, it always uses Fermat style FFT multiplication [8,9]. It takes for one full product, where k is a split value. Schonhage [9] has pointed out that the upper bound drops to if we use a computer with random access to any number of words of bounded size. For ease of calculation, we use as a final complexity of multiplication in our following analysis. Let .
2.2.2. Complexity of Modular Powering
Modular powering can be implemented by a -ary sliding window algorithm (Algorithm 14.85 in [4]). w is called the window size, which is chosen according to the size of exponent. Let l be the bit size of exponent and n be the bit size of base number, it costs around multiplications in modular powering by -ary sliding window algorithm [10]. The selection rule for w is to minimize the computing process, i.e., the cost is . To analytically solve this minimization problem and further deduce its asymptotic bound, we introduce the following lemma:
Lemma 3.
where , and .
Proof.
Let ( and ), then . Solve the inequality , it infers that . We can draw the plot of as Figure 2.
Figure 2.
Optimal w to minimize .
From Equation (4.19) in [11], it proves that while at infinity or at 0, it can be expressed as the following asymptotic formula
where , . In Figure 2, it shows that the fitting effect from asymptotic formula to exact result of is good, the coefficient of determination is close to 1.
Thus,
where , and . Figure 3 shows that fits well with the approximation formula. □
Figure 3.
Simulation of which shows that the function fits well with a linear function.
In Lemma 3, it infers that is nearly linear to the bit size of exponential number. Based on Lemma 3, we can derive the asymptotic complexity of the modular powering operation as .
2.2.3. Complexity of Normal Powering
A normal powering is always implemented by a simple binary algorithm (Section 4.6.3 algorithm A in [8]). Let e be an exponent and n be the bit size of base number, suppose is the bit size of e. It costs around multiplications in a normal powering computation, where is the amount of 1’s in binary type of e. Let .
2.2.4. Complexity of the Greatest Common Divisor
Let n be the larger size in two integers. It usually uses an binary style GCD algorithm (Section 4.5.2 algorithm B in [8]). So, we will regard as the complexity of GCD algorithm. Let .
2.3. Normal Multiplication Technique
Beyond these fundamental operations, some variants of Pollard’s P-1 algorithm like IPP1 require computing the product of a massive list of primes. The Normal Multiplication (NM) (Algorithm 1) to obtain the product of the list L is as follows. Let be an initial state, it sequentially updates the accumulator by executing for every .
As established in Corollary 1, multiplying all primes up to an n-bit integer via NM requires operations, yielding a massive product of bit-length . To resolve this computational bottleneck, we adopt a divide-and-conquer Fast Multiplication (FM) strategy (Algorithm 7). FM reduces the time cost to operations (see Corollary 2).
2.4. Overview of Pollard’s P-1 Algorithm and Its Development
Without loss of generality, we assume that the largest prime factor of is less than or equal to that of . Let a be a randomly chosen positive integer satisfying . By Fermat’s Little Theorem, any exponent z that is a multiple of satisfies . This implies that P divides , allowing us to efficiently extract the prime factor P by evaluating . Based on this fundamental property, Pollard proposed the algorithm [3], which strategically constructs the exponent z using the prime set . Specifically, by setting with sufficiently large algorithmic exponents , the algorithm guarantees that , thereby successfully factorizing N. Depending on the specific strategies used to construct this exponent z, several variants have emerged. In the remainder of this section, we review the original algorithm alongside its two prominent variants [5,6].
| Algorithm 1: Normal Multiplication Method |
![]() |
2.4.1. Original Pollard’s P-1 Algorithm [3]
To translate the aforementioned theory into practice, Pollard’s original work [3] proposed a practical two-stage approach. Let and be positive integers such that . If N is divisible by a prime factor P, the algorithm succeeds under two conditions: Stage 1. is a -smooth number; or Stage 2. , where A is a -smooth number and is a prime.
In practice, executing Stage 1 requires constructing an exponent z that covers all prime powers up to the bound . While the original paper establishes this framework, it does not explicitly specify the valuation rule for the corresponding algorithmic exponents . To address this and ensure that , subsequent formulations like Rabah’s [12] formally define as .
2.4.2. Pollard’s P-1 Algorithm in [5]
To bypass the need for a predetermined smoothness bound, a trivial variant (Algorithm 2) proposed by Bishop [5] simply increments an integer multiplier step-by-step. Starting with a random base , the method iterates through , sequentially updating and checking at each step until a non-trivial factor is found. While this exhaustive linear enumeration theoretically guarantees eventual factorization, its increment-by-one nature results in an impractically large computational overhead.
| Algorithm 2: Trivial Pollard’s P-1 Algorithm in [5] |
![]() |
2.4.3. Pollard’s P-1 Algorithm in [6]
In 2022, Somsuk [6] proposed an improved variant of Pollard’s P-1 algorithm, denoted as (Algorithm 3). Instead of processing primes individually, first computes the product of all prime numbers within a predefined list (i.e., ). It then repeatedly performs the modular exponentiation and evaluates the GCD, iterating up to a maximum bound (e.g., ). As established in Section 2.2.2, the cost of a single modular exponentiation is roughly operations (where l is the exponent’s bit size). Consequently, aggregating primes into a single product z before exponentiation is computationally cheaper than performing consecutive modular exponentiations for each eligible prime. This strategy effectively reduces the running cost when the exponents of ’s prime factors are relatively uniform. However, because uniformly raises all primes in to the same iterative power, the overall cost increases drastically if even one prime factor possesses a large exponent, as it forces redundant exponentiations for the rest of the primes (Note that [6] also proposed a second version () incorporating a linear step-by-step search as a fallback when the initial bound fails. However, since this fallback mechanism essentially mirrors the impractically expensive trivial variant discussed earlier, our analysis fundamentally focuses on ’s core aggregated-exponentiation strategy.).
| Algorithm 3: : Improved Pollard’s P-1 Algorithm in [6] |
![]() |
3. Dynamic Scaling Pollard’s P-1 Algorithm and Its Analysis
In this section, we present the details of our proposed Dynamic Scaling Pollard’s P-1 () algorithm (Section 3.1). As previously discussed, existing methods either suffer from static bound-guessing (traditional ) or incur massive redundant exponentiations when prime factors require uneven powers (). To overcome these limitations, introduces a dynamic scaling strategy that synergistically advances both the prime candidates and their respective exponents. By restructuring the traversal order and continuously reusing intermediate prime products, our variant efficiently bounds the exponents up to bits while incorporating timely GCD evaluations. Then, we provide an example to explain our improvement over in Section 3.2. Finally, we give two complexity estimators for and and a detailed theoretical analysis about their costs in Section 3.3.
3.1. Main Algorithm
As detailed in Algorithm 4, takes two primary inputs: the RSA modulus N and a smoothness bound . The parameter serves as the global upper bound for the prime candidate list with size t. By default, it can be set to the theoretical maximum to guarantee the extraction of P in the worst-case scenario. However, it strategically allows users to supply a tighter bound to significantly accelerate the factoring process if partial prior knowledge regarding the smoothness of is available.
Upon receiving these inputs, the algorithm begins its initialization. Since is inherently even, we first eliminate its factor of 2 by pre-squaring the initial base , computing , and checking (lines 1–3). If N remains unfactored after this initial check, proceeds to its core dynamic scaling phase to compute . To minimize redundant modular exponentiations and maximize overall computational efficiency, this computation processes the primes iteratively in carefully bounded subsets.
| Algorithm 4: Dynamic Scaling Pollard’s P-1 Algorithm |
![]() |
Let , , and denote the exponent applied in the j-th iteration and its intermediate constructive components, respectively. As initialized in line 5, we set and . The algorithm then iterates j from 1 to . For iterations where , we generate the j-th prime subset bounded by and compute its product . The dynamic exponent is then constructed as , and the accumulator for the next iteration is updated as . In the final iteration of this phase (i.e., ), we simply assign (lines 14–15). After determining in each iteration, we exponentiate it to the base b via (line 16). Following each exponentiation, we test whether yields a non-trivial factor. If , we have successfully recovered the prime ; otherwise, the iteration continues.
The objective of these steps is to ensure that all possible prime factors within are exponentiated to the base b with sufficiently high exponents after iterations. Based on the constructive steps, we can explicitly unroll the recurrence relations as and . Consequently, after the -th iteration completes, the base b inherently accumulates to . This guarantees that the accumulated exponent perfectly covers the required upper bounds for all primes in the generated subsets. If all prime factors of reside in , the algorithm ensures that P will be extracted.
If N remains unfactored after the loop, Phase 2 (lines 21–30) is triggered. We do not need to multiply and fully exponentiate all primes in the final subset . Since any prime in this set is strictly greater than , assuming two such primes divide yields a mathematical contradiction: . Thus, has at most one prime factor in . We bypass full modular exponentiations and instead apply Pollard’s shift modular exponentiation [3], efficiently computing where is the gap between consecutive prime candidates.
Furthermore, during the implementation of our variant, we observed that directly computing the prime subset products poses a significant computational bottleneck. To address this, we optimized the naive multiplication method by adopting a fast multiplication algorithm, which significantly accelerates the processing of the prime lists. Detailed descriptions and complexity analyses of this improvement are provided in Section 4.
3.2. Comparison of Our Algorithm with
tries to increase the utilization of the product of certain prime factors, but it can only increase efficiency when all the exponents of the prime factors are small. The probability of a small occurring is very low; therefore, we aim to minimize the cost of computing the product of numerous prime factors of (below some upper bound) and increase the utilization of the product of certain prime factors. Our variant dynamically scales each from the bit size of to the bit size , reuses the product of prime factors during exponentiation, and employs a dynamic strategy to maximize the usage rate. We provide Example 1 to illustrate why the product can be reused in the exponentiation operation and how it reduces the computation cost:
Example 1.
Given two different random prime numbers and , and a base integer a coprime to a large integer N, there are two methods to compute :
(1) First, compute the product , and then iteratively compute exponentiation by twice, i.e., calculate followed by .
(2) Directly compute the exponent and then calculate .
Let be the cost of computing in case (1), and be the cost of computing the modulo exponentiation twice in case (1). Let be the cost of computing X in case (2), and be the cost of computing in case (2). Let be the total cost of case (1), and be the total cost of case (2).
Since Lemma 3 proves that the cost of modulo exponentiation is nearly linear to the bit size of the exponent, and given that the bit size of X is approximately twice that of (i.e., ), it implies that .
However, it is obvious that computing the product incurs a higher cost than computing (the former requires one additional squaring operation). Thus, , which infers that .
In , we apply this principle to save the computational cost of evaluating by utilizing a dynamic strategy that reuses earlier products.
3.3. Cost Analysis of and
The complexity analysis of the following algorithms only considers the solvable situation, excluding the failure scenario. To establish a unified evaluation framework for both and our variant, we decompose their execution loops into four fundamental operational costs. Regardless of the specific scaling strategy, the step-wise cost (see Section 2.2 and Corollary 2) in any given phase comprises: (1) computing the product of prime candidates within a designated interval (typically via Fast Multiplication, denoted as ), (2) updating the applied exponent via standard integer multiplication (), (3) performing the core modular exponentiation (), and (4) evaluating the greatest common divisor ().
3.3.1. Complexity Analysis of
We first propose a cost estimator for Algorithm 3 to accurately simulate the cost of Algorithm 3 as Algorithm 5 and then give a theorem about the complexity of Algorithm 3 as Theorem 1.
| Algorithm 5: Est |
input: , , ; output: ;
|
Theorem 1.
(Cost Estimation for [6]) If , then N can be factored by Algorithm 3 at most
Especially, if , the cost is
Proof.
The cost for implementing Algorithm 3 while can be divided into three parts, product cost of , iterative modular powering for and iterative GCD algorithm after each modular powering. According to Corollary 2, it takes no more than operations to compute the product cost of and will get the z with bit size , where .
It takes around operations to compute the modular powering result with base a, exponent P and modulo N. It costs to compute a GCD. From Lemma 3, and .
In the declaration of Algorithm 3, the maximal exponent of prime factor in is , we will solve N after iterations of modular powering and GCD step. Thus, the total cost is
□
3.3.2. Complexity Analysis of Dynamic Scaling Pollard’s P-1 Algorithm
We first propose a cost estimator for Dynamic Scaling Pollard’s P-1 Algorithm to accurately simulate the cost of our variant as Algorithm 6 and then give a theorem about the complexity of our variant as Theorem 2.
| Algorithm 6: Est |
![]() |
Theorem 2.
(Cost Estimation for Our Variant) The complexity in factoring N successfully by our Dynamic Scaling Pollard’s P-1 Algorithm (Algorithm 4) is as follows,
If , then the cost of Dynamic Scaling Pollard’s P-1 Algorithm is
Proof.
(1) If , N will be factored in the process of Algorithm 4 declared from line 9 to 31 with loops. The cost in case (1) contains the computations of set , and , the modular powering operation for each element from to k and a GCD operation in the end of each iteration.
For set , the minimal bit size of is and the maximal bit size of is . Let , according to Corollary 2 and the description of line 12 in Algorithm 4, it takes no more than
to compute the product cost of and will get with the bit size
Since , and , it infers that the bit size of is
while and
for .
The cost for computing each is and get with the bit size
The cost for computing each is .
The cost for modular powering operation is and the GCD operation costs in each loop. From Lemma 3, we can get that
and
So the total cost is
□
4. Fast Multiplication Technique and Its Analysis
This section details our Fast Multiplication (FM) method (Section 4.1). We provide formal cost estimators and theoretical complexity analyses for both NM (see Section 2.2) and FM methods in Section 4.2, followed by experimental validation in Section 4.3. Ultimately, we demonstrate theoretically and empirically that standard multiplication incurs a time overhead times higher than FM when computing the product of all primes up to n bits.
4.1. Fast Multiplication Technique
Given a list defined in Section 2, NM introduced in Section 2.2 degrades rapidly for large lists because the accumulating product x grows drastically. Since computational cost depends heavily on the bit-length of the largest multiplier, this skewed growth inherently throttles efficiency. To accelerate it, we propose the FM algorithm (Algorithm 7). Given a sorted list L () of positive integers, FM operates recursively: During each iteration, if the current list length k is odd, a trivial multiplier 1 is prepended to the sequence. The elements are then extracted as to pairwise multiply the symmetrically opposite ends: computing for . These temporary products form the updated sequence L, effectively halving the size parameter . This iterative process is repeated until only a single final product remains.
By continually balancing the bit-sizes of the intermediate multipliers, FM significantly reduces the calculation time compared to standard sequential multiplication. We mathematically formalize and prove this efficiency gain for uniformly distributed inputs in Section 4.3.
| Algorithm 7: Fast Multiplication Method (FM) |
![]() |
4.2. Complexity Analysis of Normal Multiplication and Fast Multiplication
4.2.1. Complexity Analysis of Normal Multiplication Method
To fully evaluate the efficiency gains of our proposed algorithms, it is necessary to first analyze the time complexity of NM (Section 2.3). It computes the total product by iteratively multiplying elements one by one. Theorem 3 establishes the theoretical upper bound on the computational cost for computing the product of the list L.
Theorem 3
(Time Complexity of the NM). Assume is an ascending list defined in Section 2 with a size strictly greater than 3. Multiplying all elements in L using the NM requires around operations. In particular, when , the computational cost is
Proof.
Suppose the largest integer in list L is a and n is the bit size of a. Since p is the probability of a number occurring in list L, the total amount of numbers in L is expected to be . When , the initial list L covers all positive integers up to .
The normal multiplication method iteratively multiplies the elements in L. Let the accumulator be . For ease of discussion, we process the multipliers grouped by their bit sizes. In the iteration for bit size i (where ), we multiply the accumulator by all elements in L that have exactly i bits (i.e., integers in the range ). There are expected to be such multipliers.
According to Lemma 1, at the start of the iteration for bit size i, the expected bit size of the accumulator is
During the iterations of bit size i, we perform multiplications. Each multiplier contributes approximately i bits to the accumulator. Therefore, the k-th multiplication in this stage involves an accumulator of bit size . Let be the computational cost for the iteration of bit size i. Considering the time cost of each multiplication in Section 2.2.1, we have . Since and and Applying Lemma 2 by substituting and , we have
Thus, the total time complexity is the summation of over all bit sizes i from 3 to n. Using the geometric series approximation , we obtain:
In particular, when , the computational cost simplifies to □
Corollary 1.
For all prime numbers smaller or equal to the maximal n-bit positive integer , it takes at most
operations to multiply all these numbers together by Algorithm 1 and get smaller than or equal to -bit positive integer.
4.2.2. Complexity Analysis of FM
Due to the intricate nature of the complexity analysis for FM, we first propose a cost estimator to accurately simulate its computational overhead. Suppose L is a list containing strictly more than three distinct positive integers, where the minimum and maximum bit sizes of its elements are and , respectively. Let p be the probability of an integer appearing in L. The cost evaluation is formalized in Algorithm 8. By taking parameters , , and p as inputs, it returns the estimated computational cost .
Theorem 4.
(Cost of FM Algorithm) Assume is an ascending list defined in Section 2 with a size strictly greater than 3. It takes roundly
operations to compute the product of L by FM (Algorithm 7). Especially, while , we have
| Algorithm 8: FastMulCostEst |
![]() |
Proof.
Since the minimum and maximum bit size of integers in list L are and (), the amount of the positive integers in the range of is and p is the probability of a number occurring in list L. It infers that the initial list L could be with size while . We could add 1’s into L.
It performs non-trivial multiplications in the first fold-in-half stage. Since the amount of k-bit positive integers is , it computes products of an -bit number and a k-bit number for in each multiplication and remain -bit numbers. It costs operations at the first-iter and obtains numbers in total and store them in an empty list L for next multiplications as Table 1.
Table 1.
Bit size in L after 1st iteration in FM.
For the second iteration, it performs multiplications. It computes products of a -bit number and an -bit number in each multiplication, products of a -bit number and a -bit number for in each multiplication. It costs operations at the second-iter and obtains numbers in total and store them in an empty list L for next multiplications as the Table 2.
Table 2.
Bit size in L after 2nd iteration in FM.
For the i-th-iter (), it applies to multiplications. It computes products of a -bit number and a -bit number and products of a -bit number and a -bit number for in each multiplication. It costs operations at the i-th-iter. It obtains numbers in total and store them in an empty list L for next multiplications as Table 3.
Table 3.
Bit size in L after i-th iteration in FM.
For the -th-iter, it applies to multiplications. It computes products of a -bit number and a -bit number in each multiplication. It costs operations at the -th-iter, then we obtain products with bit size at most -bit.
For the -th-iter (), it applies to multiplications. It computes products of two -bit numbers in each multiplication. It costs operations at the -th-iter, then we obtain products with bit size at most -bit. We get the last product of FM with bit size while .
Let , , then
All in all, we add up all the overhead and get the time cost of the FM (Algorithm 7):
While , it infers that the amount of numbers in list L is . Thus, we get that the bit size of the product is and
the total cost is
□
Corollary 2.
For all prime numbers smaller or equal from -bit to -bit positive integer, it takes at most
operations to multiply all these numbers together by Algorithm 7. Let .
Proof.
According to Prime Theorem, the number of primes in is . We can regard the prime numbers declared in Corollary 2 as a non-repeated list L on , then the probability that each number occurs in L is . According to Theorem 4, it takes at most
operations to multiply all these numbers together by Algorithm 7. □
4.3. Comparison Between Normal Multiplication Method and FM
We give a comparison between normal multiplication method and FM and obtain that the cost of FM is lower than normal multiplication method while the number in list L is uniformly distributed in for an arbitrary positive integer and the element in L is not repeated. The cost of FM is according to Corollary 2.
Figure 4 shows that the theoretical complexity analysis fits the actual cost. In Figure 4, the orange points denote the actual cost for normal multiplication method to compute the product of all the primes less than or equal to the bit size shown in x-coordinate. The red points imply the actual cost for FM to compute the product of all the primes less than or equal to the bit size shown in x-coordinate. The gray line and the red line corresponds to the theoretical complexity of normal multiplication method and FM. It shows that with more elements added in the list for multiplication, the time overhead of normal multiplication method will increase by times higher than which of FM.
Figure 4.
Experimental result of normal multiplication method and FM. The red star point (orange point) is the experimental cost of normal/fast multiplication method, which computes the cost of all primes smaller than or equal to the bit size shown in x-coordinate. The gray (red) dashed line is the theoretical cost of normal/fast multiplication method. It fits the experimental result, which means that the theoretical analysis is correct.
5. Comparison Among Four Variants of Pollard’s P-1 Algorithm
5.1. Theoretical Comparison Between and
In , it selects a prime , then compute the product and iteratively calls a modular exponential operation at most times to ensure all the prime factors for contained in . After that it can factor N by compute for a randomly chosen base a which is coprime to N. We can see that if , then it produces an unnecessary overhead to calculate the exponent value for in . Figure 5 shows such an overhead in the condition . In our variant, we grow the exponents of each parallelly to the upper bound to avoid enumerating more invalid exponent as expressed in Figure 6 (more details about our variant can be seen in Section 3.1). The green part and red part denote the calculation amount for each and its exponent number . The blue arrow implies that the calculation quantities in green part of (Figure 5) or our variant (Figure 6) gradually grows to red part. The orange dash line can be considered to represent the calculation amount when the solution is successful. The variant solve the solution successfully only if the red part covers the orange dash line and all of its left area. It shows that our calculation amount is significantly lower than .
Figure 5.
Exponent growth in [6]. The x axis is the prime number, the y axis means the exponent value of each prime. The purple line shows a sample with the prime factors and its exponent number of . The blue arrow denotes the growth direction for adding new prime factors in . The orange line means the representation of . If the index value exceeds the orange line, it means that we increase the extra index of the prime factor . The red block means the minimal scope to add prime numbers through .
Figure 6.
Exponent growth in our variant. The x axis is the prime number, the y axis means the exponent number of each prime. The purple line shows a sample with the prime factors and its exponent number of . The blue arrow denotes the growth direction for adding new prime factors in our variant. The orange line means the representation of . If the index value exceeds the orange line, it means that we increase the extra index of the prime factor . The green block indicates the steady incremental allocation of exponents that drives the DSP cost toward its asymptotic scaling. The red block means the minimal scope to add prime numbers through our variant.
From the Theorem 1 and Theorem 2, the cost of finding the factor prime through our variant could be lower than while . Since , it infers that . Since in general, . We consider the probability of as , where function is defined in the page 162 of [13]. Suppose , then . In page 163 of [13], it shows that and is a monotonically decreasing function, so while . Thus, in high probability while , i.e., our algorithm is more efficiency than in most of the time. Since itself presets the size of B, it is expected that it will not set B below 64. In this case, even if the prime factors of are less than 64, our algorithm will still be faster.
5.2. Experimental Comparison Among 4 Variants of Pollard’s P-1 Algorithm
We’ve implemented Pollard’s P-1 algorithm in [3,5], with fast multiplication technique as well as our variant (https://github.com/Summwer/expemeriment_of_pollardpm1, accessed on 1 August 2026). We design a prime generator to generate P so that is the product of several randomly generated 30-bit integers, which ensures the maximal prime factor of is the largest prime smaller than . Then, we use the P to generate a random prime Q that in the same bit size of P and compute . We test the above four algorithms in comparing the cost of factoring 10 entries of 1024-bit N, which was randomly generated by the above generator. We implement the test in a personal laptop (20.04.1-Ubuntu, x86-64, 6*Intel® Core™ i5-9500 CPU @ 3.00GHz, RAM 16 GB) with single thread. The experiment result is shown in Figure 7, we can see that our variant is around 23.5/16.4/35.6 times faster than the Algorithm /[3]/[5]. It shows that our algorithm has an absolute advantage in factoring an N with that the corresponding ’s factors have high exponents. In Figure 7, we can also find out that a randomly generated the product of several randomly generated 30-bit number has prime factors with high exponent (at least larger than 1) in high probability (instance 2,3,4,5,8). For some cases (instance 2,3,4,8), the is slower than the original Pollard’s P-1, but in this case we are still faster than the original Pollard’s P-1. Since the multipliers in are chosen in randomly in Figure 7, it can be seen that the number of prime factors of or the size of the prime factor index have little impact on the complexity of our variant. Only the size of the largest prime factor is the only key influencing factor in our variant.
Figure 7.
Practical cost for our variant (blue one), (orange one), Original Pollard’s P-1 Algorithm [3] (green one) and Trivial Pollard’s P-1 Algorithm [5] (red one) to factor an 1024-bit N. The x-axis is the index for the randomly generated instance. The y-axis is the cost in second.
For the second experiment, we consider a situation that one prime factor of has a high exponent. We construct a 512-bit prime P in the form of (z is a number s.t. the larger entry satisfying for ) and a randomly 512-bit Q. Given , we estimate the cost of our variant and both in estimators (Algorithms 5 and 6) and the Theoretical Complexity Theorems (Theorems 1 and 2). We test the same instances in our variant (Algorithm 4) and (Algorithm 3), Figure 8 shows that theoretical complexity fits well to the cost in both estimator and experiment.
Figure 8.
The figure shows growth accuracy for and with a 1024-bit N and 512-bit primes P, Q with ; the x-axis is and the y-axis is cost in cycles. Experimental results are marked by green triangles () and blue circles (), estimator predictions by yellow triangles () and red circles (), while theoretical costs are given by a dashed line (, Theorem 2) and a dash-dotted line (, Theorem 1).
6. Conclusions
We propose a variant of Pollard’s P-1 named Dynamic Scaling Pollard’s P-1 Algorithm. The proposed algorithm is an efficient method when all prime factors of or are small. The proposed algorithm is quicker than previous Pollard’s P - 1 Algorithms for virtually all values of the modulus (especially has a prime factor with a high index), according to the experimental findings and the complexity analysis result. In factoring 1024-bit integer, our algorithm solves it nearly 23.5/16.4/35.6 times faster than the Algorithm [6]/[3]/[5]. We also give a theoretical comparison between our and , it concludes that our algorithm costs lower than in more than 95% while the upper bound of prime list B in is set to be larger than 64.
Author Contributions
Conceptualization, W.X.; methodology, W.X.; software, W.X.; validation, W.X.; formal analysis, W.X.; investigation, W.X.; resources, D.G.; data curation, W.X.; writing—original draft preparation, W.X.; writing—review and editing, W.X.; visualization, W.X. and G.W.; supervision, G.W. and D.G.; project administration, G.W. and D.G.; funding acquisition, G.W. and D.G. All authors have read and agreed to the published version of the manuscript.
Funding
This research was funded by National Cryptologic Science Fund of China No. 2025NCSF02017.
Data Availability Statement
The raw data supporting the conclusions of this article will be made available by the authors on request.
Conflicts of Interest
The authors declare no conflicts of interest.
References
- Rivest, R.L.; Shamir, A.; Adleman, L. A method for obtaining digital signatures and public-key cryptosystems. Commun. ACM 1978, 21, 120–126. [Google Scholar] [CrossRef] [Scilit]
- Buhler, J.P.; Lenstra, H.W.; Pomerance, C. Factoring integers with the number field sieve. In The Development of the Number Field Sieve; Lecture Notes in Mathematics; Lenstra, A.K., Lenstra, H.W., Eds.; Springer: Berlin/Heidelberg, Germany, 1993; Volume 1554, pp. 50–94. [Google Scholar] [CrossRef] [Scilit]
- Pollard, J.M. Theorems on factorization and primality testing. Math. Proc. Camb. Philos. Soc. 1974, 76, 521–528. [Google Scholar] [CrossRef] [Scilit]
- Menezes, A.J.; van Oorschot, P.C.; Vanstone, S.A. Handbook of Applied Cryptography, 1st ed.; CRC Press: Boca Raton, FL, USA, 2018. [Google Scholar] [CrossRef] [Scilit]
- Bishop, D. Introduction to Cryptography with Java Applets; Jones and Bartlett: Boston, MA, USA, 2003. [Google Scholar]
- Somsuk, K. An Efficient Variant of Pollard’s p − 1 for the Case That All Prime Factors of the p − 1 in B-Smooth. Symmetry 2022, 14, 312. [Google Scholar] [CrossRef] [Scilit]
- Avigad, J.; Donnelly, K.; Gray, D.; Raff, P. A formally verified proof of the prime number theorem. ACM Trans. Comput. Log. 2007, 9, 2. [Google Scholar] [CrossRef] [Scilit]
- Ruckert, M.; Knuth, D.E. The Art of Computer Programming; Addison-Wesley: Upper Saddle River, NJ, USA, 2015. [Google Scholar]
- Schönhage, A.; Strassen, V. Schnelle Multiplikation großer Zahlen. Computing 1971, 7, 281–292. [Google Scholar] [CrossRef] [Scilit]
- Möller, B. Sliding Window Exponentiation. In Encyclopedia of Cryptography and Security; van Tilborg, H.C.A., Jajodia, S., Eds.; Springer: Boston, MA, USA, 2011; pp. 1222–1224. [Google Scholar] [CrossRef] [Scilit]
- Corless, R.M.; Gonnet, G.H.; Hare, D.E.G.; Jeffrey, D.J.; Knuth, D.E. On the LambertW function. Adv. Comput. Math. 1996, 5, 329–359. [Google Scholar] [CrossRef] [Scilit]
- Rabah, K. Review of Methods for Integer Factorization Applied to Cryptography. J. Appl. Sci. 2006, 6, 458–481. [Google Scholar] [CrossRef] [Scilit]
- Riesel, H. Prime Numbers and Computer Methods for Factorization; Birkhäuser: Boston, MA, USA, 2012. [Google Scholar] [CrossRef] [Scilit]
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content. |
© 2026 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license.














