Click or drag to resize

MathUtilsRhoFactor Method

Attempts to find a factor of a number, searching for a small factor first before using the Pollard Rho algorithm.

Namespace: Orthogonal.Common.Basic
Assembly: Orthogonal.Common.Basic (in Orthogonal.Common.Basic.dll) Version: 2024-04-15 18:00 GMT+10.f27da1471008deaf16b803c17e24a5955690aef1
Syntax
C#
public static BigInteger RhoFactor(
	BigInteger n,
	out BigInteger unfactored,
	Action<RhoCallbackReason, int, BigInteger> rhoCallback
)

Parameters

n  BigInteger
The number to factor.
unfactored  BigInteger
The unfactored quotient resulting from dividing the input value n by the found factor. A zero value indicates that the value n is a prime or probable prime.
rhoCallback  ActionRhoCallbackReason, Int32, BigInteger
A callback delegate that can be used to trace factoring progress. Null for no callbacks.

Return Value

BigInteger
A factor of the input number n. If n is prime then n is returned and the unfactored value is zero.
Remarks
If the input value n is a probable prime then it is returned unchanged as a trivial factor. A sequential search through the first 1000 primes will return the first found factor. Finally the Pollard Rho algorithm is used to search for a factor. Each time the Rho algorithm fails the internal quadratic z2+c iteration will increment the c value by 2 from an intial value of 1 and restart.
See Also