private void DoFactorize(object o) { if (o == null) { return; } Dictionary <PrimesBigInteger, long> factors = null; PrimesBigInteger value = null; if (o.GetType() == typeof(PrimesBigInteger)) { ControlHandler.SetPropertyValue(lblCalcFactorizationInfo, "Text", Distribution.numberline_factorizationcalculating); value = o as PrimesBigInteger; factors = value.Factorize(); } else if (o.GetType() == typeof(Dictionary <PrimesBigInteger, long>)) { factors = o as Dictionary <PrimesBigInteger, long>; value = PrimesBigInteger.Refactor(factors); } if (factors != null) { String s = value.ToString(); if (!value.IsPrime(20) && !value.Equals(PrimesBigInteger.One)) { s += " = " + String.Join(" * ", factors.Keys.Select(i => i + ((factors[i] > 1) ? "^" + factors[i] : "")).ToArray()); } ControlHandler.SetPropertyValue(lblFactors, "Visibility", Visibility.Visible); ControlHandler.SetPropertyValue(lblFactors, "Text", s); } if (FactorizationDone != null) { FactorizationDone(); } }
private void MarkNumber(PrimesBigInteger value) { if (m_ActualNumber != null && m_ActualNumber.Equals(value)) { return; } UnmarkAllNumbers(); CancelThreads(); MarkNumberWithOutThreads(value); Dictionary <PrimesBigInteger, long> factors = value.Factorize(); Factorize(factors); CalculateGoldbach(value); CountPrimes(value); m_EulerPhi.Start(value, factors); m_Tau.Start(value, factors); m_Rho.Start(value, factors); m_DivSum.Start(value, factors); ControlHandler.SetButtonEnabled(btnCancelAll, true); }