コード例 #1
0
ファイル: EquationParts.cs プロジェクト: Eric7Apps/BlogSource
        internal EquationParts( QuadResWorkerInfo UseWInfo, BackgroundWorker UseWorker )
        {
            WInfo = UseWInfo;
            Worker = UseWorker;
            IntMath = new IntegerMath();
            Quotient = new Integer();
            Remainder = new Integer();
            Product = new Integer();
            SolutionP = new Integer();
            SolutionQ = new Integer();
            ProductSqrRoot = new Integer();
            MaxX = new Integer();
            FindFactors1 = new FindFactors(  Worker, IntMath );

            IntMath.SetFromString( Product, WInfo.PublicKeyModulus );
        }
コード例 #2
0
        private bool IsSolution( Integer X, Integer Y )
        {
            Worker.ReportProgress( 0, " " );
            Worker.ReportProgress( 0, "Top of IsSolution()." );
            FindFactors FindF = new FindFactors( Worker, IntMath );
            FindF.FindSmallPrimeFactorsOnly( Y );
            FindF.ShowAllFactors();

            SolutionP.Copy( Y );
            IntMath.Subtract( SolutionP, X );

            // Make Q the bigger one and put them in order.
            SolutionQ.Copy( Y );
            SolutionQ.Add( X );

            if( SolutionP.IsOne() )
              {
              Worker.ReportProgress( 0, " " );
              Worker.ReportProgress( 0, "Went all the way to 1 without finding a factor." );
              SolutionP.SetToZero(); // It has no factors.
              SolutionQ.SetToZero();
              throw( new Exception( "Went all the way to 1 without finding a factor." ));
              // return false;
              }

            Worker.ReportProgress( 0, "Found P: " + IntMath.ToString10( SolutionP ) );
            Worker.ReportProgress( 0, "Found Q: " + IntMath.ToString10( SolutionQ ) );
            Worker.ReportProgress( 0, "Seconds: " + StartTime.GetSecondsToNow().ToString( "N1" ));
            double Seconds = StartTime.GetSecondsToNow();
            int Minutes = (int)Seconds / 60;
            int Hours = Minutes / 60;
            Minutes = Minutes % 60;
            Seconds = Seconds % 60;
            string ShowS = "Hours: " + Hours.ToString( "N0" ) +
                   "  Minutes: " + Minutes.ToString( "N0" ) +
                   "  Seconds: " + Seconds.ToString( "N0" );

            Worker.ReportProgress( 0, ShowS );

            Worker.ReportProgress( 0, " " );
            return true; // With P and Q.
        }