Direct Search Factorization

Direct search factorization is the simplest (and most simple-minded) prime factorization algorithm. It consists of searching for factors of a number by systematically performing trial divisions, usually using a sequence of increasing numbers. Multiples of small primes are commonly excluded to reduce the number of trial divisors, but just including them is sometimes faster than the time required to exclude them. Direct search factorization is very inefficient, and can be used only with fairly small numbers.

When using this method on a number n, only divisors up to |_sqrt(n)_| (where |_x_| is the floor function) need to be tested. This is true since if all integers less than this had been tried, then


In other words, all possible factors have had their cofactors already tested. It is also true that, when the smallest prime factor p of n is >RadicalBox[n, 3], then its cofactor m (such that n=pm) must be prime. To prove this, suppose that the smallest p is >RadicalBox[n, 3]. If m=ab, then the smallest value a and b could assume is p. But then


which cannot be true. Therefore, m must be prime, so


See also

Prime Factorization Algorithms, Trial Division

Explore with Wolfram|Alpha

Cite this as:

Weisstein, Eric W. "Direct Search Factorization." From MathWorld--A Wolfram Web Resource.

Subject classifications