From cff0316c0ad442f1f432d38837ea038a81c2f665 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Wed, 26 Feb 2025 13:57:40 +0100 Subject: [PATCH] Optimize stop factor after every found factor --- src/FactorizationController.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/FactorizationController.cpp b/src/FactorizationController.cpp index 105c1f9..803c0ab 100644 --- a/src/FactorizationController.cpp +++ b/src/FactorizationController.cpp @@ -185,6 +185,16 @@ void FactorizationController::factorize() { emit factorsChanged(); emit curFactNumberChanged(); + // As a further optimization, we can adjust the stop factor to the sqrt of + // the new number being factorized, rather than keeping it at the original number. + // (This might make the progress bar jump radically) + if (m_useSqrtOptimization) { + m_stopFactor = static_cast(std::sqrt(m_currentFactNumber)); + } else { + m_stopFactor = m_currentFactNumber - 1; + } + emit progressChanged(); + // Don't increase current factor, keep dividing by it until no longer divisible } else { m_currentFactor++;