Optimize stop factor after every found factor

This commit is contained in:
ItsDrike 2025-02-26 13:57:40 +01:00
parent 5946e3ac82
commit cff0316c0a
Signed by: ItsDrike
GPG key ID: FA2745890B7048C0

View file

@ -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<long long>(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++;