-
Notifications
You must be signed in to change notification settings - Fork 1
Factorization algorithm
David Hofer edited this page Apr 20, 2016
·
3 revisions
The algorithm for factoring a number n
as I've implemented it goes something like the following.
-
Trial division. Using a precomputed number of primes (currently all those less than 1 million), test if any divide
n
. If so, add them as factors, dividen
by them, and continue. -
See if n is a perfect power (in which case its factors are easy to get). Details here: https://github.com/dkhofer/primes/wiki/Finding-perfect-powers
-
See if Pollard's Rho algorithm turns up any factors: https://github.com/dkhofer/primes/wiki/Pollard's-Rho-algorithm
-
Brute force
In the future, I plan to add in one or more number sieve algorithms.