Examples - pi.science.discretemath.PIPrimeFactorizationSimple
1. How to make prime factorization ?
readonly PIPrimeFactorizationSimple factorization = new PIPrimeFactorizationSimple(); /* 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( 2 ); FactorizeItem( 123 ); FactorizeItem( 500 ); FactorizeItem( 54868 ); FactorizeItem( 45486857 ); FactorizeItem( 454868572 );
Output:
2 => 2 = 2 123 => 3*41 = 3*41 500 => 2*2*5*5*5 = (2^2)*(5^3) 54868 => 2*2*11*29*43 = (2^2)*11*29*43 45486857 => 13*13*79*3407 = (13^2)*79*3407 454868572 => 2*2*5743*19801 = (2^2)*5743*19801