Java Program to Implement Pollard Rho Algorithm
Pollard’s rho algorithm is an algorithm for integer factorization. It is particularly effective at splitting composite numbers with small factors. The Rho algorithm’s most remarkable success was the factorization of eighth Fermat number: 1238926361552897 * 93461639715357977769163558199606896584051237541638188580280321. This algorithm was a good choice for F8 because the prime factor p = 1238926361552897 is much smaller than the other factor.
Input: n = 315 Output: 3 [OR 3 OR 5 OR 7] Input: n = 10 Output: 2 [OR 5 ]
- The algorithm takes as its inputs n.
- The integer N to be factored, and g(x).
- A polynomial in x computed modulo n.
g(x) = (x^2 + 1) % n
The output is either a non-trivial factor of n or failure.
Example: Let us suppose n = 187, y = x = 2 and c = 1, Hence, our g(x) = x^2 + 1.
11 is a non-trivial factor of 187.
Below is a Java program to Implement Pollard Rho Algorithm:
One of the prime factor of 315 is 5
Time Complexity: O(sqrt(n))