nzmath . factor

find

All methods defined here return one of a factor of given integer. When 1 is returned, the method has failed to factor, but 1 is a factor anyway.

'verbose' boolean flag can be specified for verbose reports.

Functions

pmom(n [, **options])

The function tries to find a non-trivial factor of n using Algorithm 8.8.2 (p-1 first stage) of Cohen. In case of n = pow(2,i), the function will not terminate. As the nature of the method, a factorization may find only the trivial factor.

rhomethod(n [, **options])

Find a non-trivial factor of n using Pollard's rho algorithm. The implementation refers the explanation in Crandall & Pomerance. As the nature of the method, a factorization may find only the trivial factor.

trialDivision(n[, **options])

Return a factor of given integer by trial division.

options can be either:

  1. 'start' and 'stop' as range parameters.
  2. 'iterator' as an iterator of primes.

If both options are not given, prime factor is searched from 2 to the square root of the given integer.


Last-modified: 2005-12-18 (Æü) 17:53:48