Examples - pi.science.discretemath.PIPrimeFactorizationFermat
1. How to make prime factorization using Fermat algorithm ?
readonly PIPrimeFactorizationFermat factorization = new PIPrimeFactorizationFermat();
/* Factorization - display item. */
private void FactorizeItem( long _value ) {
factorization.Value = _value;
factorization.Factorize();
Console.Write( factorization.Value + " => " );
Console.WriteLine( factorization.ResultAsMultipleString() + " = " + factorization.ResultAsMultipleWithExpString() );
PIDebug.Blank();
}
FactorizeItem( 123 );
FactorizeItem( 501 );
FactorizeItem( 54869 );
FactorizeItem( 45486857 );
FactorizeItem( 454868571 );
Output:
123 => 3*41 = 3*41
501 => 3*167 = 3*167
54869 => 1*54869 = 1*54869
45486857 => 3407*13351 = 3407*13351
454868571 => 3*151622857 = 3*151622857