Skip to content

Commit 1afaf04

Browse files
Correct heuristics
1 parent a95d424 commit 1afaf04

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

FindAFactor/_find_a_factor.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1124,7 +1124,7 @@ std::string find_a_factor(std::string toFactorStr, size_t method, size_t nodeCou
11241124
}
11251125

11261126
// This level default (scaling) was suggested by Elara (OpenAI GPT).
1127-
const double N = sqrtN.convert_to<double>();
1127+
const double N = toFactor.convert_to<double>();
11281128
const double logN = log(N);
11291129
const BigInteger primeCeilingBigInt = (BigInteger)(smoothnessBoundMultiplier * pow(exp(0.5 * std::sqrt(logN * log(logN))), std::sqrt(2.0) / 4) + 0.5);
11301130
const size_t primeCeiling = (size_t)primeCeilingBigInt;
@@ -1217,7 +1217,7 @@ std::string find_a_factor(std::string toFactorStr, size_t method, size_t nodeCou
12171217
futures.reserve(CpuCount);
12181218

12191219
if (isFactorFinder) {
1220-
const BigInteger sievingNodeRange = (BigInteger)(sqrtN.convert_to<double>() * sievingBoundMultiplier / nodeCount + 0.5);
1220+
const BigInteger sievingNodeRange = (BigInteger)(std::sqrt(toFactor.convert_to<double>()) * sievingBoundMultiplier / nodeCount + 0.5);
12211221
const BigInteger sievingThreadRange = sievingNodeRange / CpuCount;
12221222
const BigInteger nodeOffset = nodeId * sievingNodeRange;
12231223
for (unsigned cpu = 0U; cpu < CpuCount; ++cpu) {

0 commit comments

Comments
 (0)