IntegerMath.Factor Method

Definition

Namespace: Extreme.Mathematics
Assembly: Extreme.Numerics (in Extreme.Numerics.dll) Version: 8.1.23

Overload List

Factor(Int32) Returns the prime factors of an integer.
Factor(Int64) Returns the prime factors of an integer.

Factor(Int32)

Returns the prime factors of an integer.
C#
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

ArgumentOutOfRangeExceptionn is less than or equal to zero.

Factor(Int64)

Returns the prime factors of an integer.
C#
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

ArgumentOutOfRangeExceptionn is less than or equal to zero.

See Also