Integer Math.Factor Method
Definition
Namespace: Numerics.NET
Assembly: Numerics.NET (in Numerics.NET.dll) Version: 9.0.0
Assembly: Numerics.NET (in Numerics.NET.dll) Version: 9.0.0
Overload List
Factor( | Returns the prime factors of an integer. |
Factor( | Returns the prime factors of an integer. |
Factor(Int32)
Returns the prime factors of an integer.
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)
Returns the prime factors of an integer.
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. |