Skip to content

Commit aee0cc6

Browse files
Other side of equation need not have smooth prime factors
1 parent 1afaf04 commit aee0cc6

File tree

1 file changed

+3
-48
lines changed

1 file changed

+3
-48
lines changed

FindAFactor/_find_a_factor.cpp

Lines changed: 3 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -773,14 +773,9 @@ struct Factorizer {
773773
for (BigInteger y = backwardFn(toFactorSqrt + 1U + low); isIncomplete && (y < maxLcv); ++y) {
774774
// Make the candidate NOT a multiple on the wheels.
775775
const BigInteger z = forwardFn(y);
776-
// This actually just goes ahead and FORCES
777-
// the number into a "close-by" smooth perfect square.
778-
const BigInteger candidate = makeSmooth(z * z);
779-
// We want each number to be larger than toFactor.
780-
if (candidate < toFactor) {
781-
continue;
782-
}
783-
// The residue (mod N) also needs to be smooth (but not a perfect square).
776+
// Make the candidate a perfect square.
777+
const BigInteger candidate = (z * z);
778+
// The residue (mod N) needs to be smooth (but not a perfect square).
784779
// The candidate is guaranteed to be between toFactor and its square,
785780
// so subtracting toFactor is equivalent to % toFactor.
786781
const boost::dynamic_bitset<size_t> rfv = factorizationParityVector(candidate - toFactor);
@@ -1013,46 +1008,6 @@ struct Factorizer {
10131008
throw std::runtime_error("No solution produced a congruence of squares. (We found and tried " + std::to_string(result.solutionColumns.size()) + ", but even 1 should maybe be enough.)");
10141009
}
10151010

1016-
// Produce a smooth number with its factorization vector.
1017-
BigInteger makeSmooth(BigInteger num) {
1018-
BigInteger n = num;
1019-
while (true) {
1020-
// Proceed in steps of the GCD with the smooth prime wheel radius.
1021-
BigInteger factor = gcd(n, diffWheelRadius);
1022-
if (factor == 1U) {
1023-
break;
1024-
}
1025-
n /= factor;
1026-
// Remove smooth primes from factor.
1027-
// (The GCD is necessarily smooth.)
1028-
for (size_t pi = afterGearPrimeId; pi < smoothPrimes.size(); ++pi) {
1029-
const size_t& p = smoothPrimes[pi];
1030-
if (factor % p) {
1031-
continue;
1032-
}
1033-
factor /= p;
1034-
if (factor == 1U) {
1035-
// The step is fully factored.
1036-
break;
1037-
}
1038-
}
1039-
if (n == 1U) {
1040-
// The number is fully factored and smooth.
1041-
break;
1042-
}
1043-
}
1044-
if (n != 1U) {
1045-
// The number was not fully factored, because it is not smooth.
1046-
// Make it smooth, by dividing out the remaining non-smooth factors!
1047-
num /= n;
1048-
// This probably won't work, for the sieve, but notice that it is
1049-
// basically no more expensive, at this point, to try this.
1050-
}
1051-
1052-
// This number is necessarily smooth.
1053-
return num;
1054-
}
1055-
10561011
// Compute the prime factorization modulo 2
10571012
boost::dynamic_bitset<size_t> factorizationParityVector(BigInteger num) {
10581013
boost::dynamic_bitset<size_t> vec(smoothPrimes.size(), 0U);

0 commit comments

Comments
 (0)