Integer Math.Factor Method
Definition
Assembly: Extreme.Numerics (in Extreme.Numerics.dll) Version: 8.1.23
Overload List
Factor( | Returns the prime factors of an integer. |
Factor( | Returns the prime factors of an integer. |
Factor(Int32)
public static IEnumerable<(int , int )> Factor(
int n
)
Parameters
- n Int32
- An integer greater than zero.
Return Value
IEnumerable<ValueTuple<Int32, Int32>>An integer array containing the prime factors of n in ascending order.
Remarks
This method uses a simple trial divide algorithm to look for small prime factors. It then switches to Pollard's Rho algorithm to find any large prime factors of n with the known factors divided out. If this number is prime, the algorithm may take a long term to finish.
Exceptions
Argument | n is less than or equal to zero. |
Factor(Int64)
public static IEnumerable<(long , int )> Factor(
long n
)
Parameters
- n Int64
- An integer greater than zero.
Return Value
IEnumerable<ValueTuple<Int64, Int32>>An integer array containing the prime factors of n in ascending order.
Remarks
This method uses a simple trial divide algorithm to look for small prime factors. It then switches to Pollard's Rho algorithm to find any large prime factors of n with the known factors divided out. If this number is prime, the algorithm may take a long term to finish.
Exceptions
Argument | n is less than or equal to zero. |