@@ -827,11 +827,8 @@ struct Factorizer {
827827 const BigInteger bIndex = dis (gen) % threadRange;
828828 const BigInteger halfBIndex = threadOffset + (bIndex >> 1U ) + 1U ;
829829 const BigInteger bNum = (bIndex & 1U ) ? halfBIndex : (batchTotal - halfBIndex);
830- const BigInteger n = forwardFn ((bNum * wheelEntryCount) + (dis (gen) % wheelEntryCount));
831- const std::vector<size_t > pfv = factorizationVector (n);
832- if (!pfv.size ()) {
833- continue ;
834- }
830+ BigInteger n = forwardFn ((bNum * wheelEntryCount) + (dis (gen) % wheelEntryCount));
831+ const std::vector<size_t > pfv = factorizationVector (&n);
835832 perfectSquare *= n;
836833 for (size_t pi = 0U ; pi < primes.size (); ++pi) {
837834 fv[pi] += pfv[pi];
@@ -971,7 +968,8 @@ struct Factorizer {
971968 }
972969
973970 // Compute the prime factorization.
974- std::vector<size_t > factorizationVector (BigInteger num) {
971+ std::vector<size_t > factorizationVector (BigInteger* numPtr) {
972+ BigInteger num = *numPtr;
975973 std::vector<size_t > vec (primes.size (), 0 );
976974 while (true ) {
977975 // Proceed in steps of the GCD with the smooth prime wheel radius.
@@ -999,9 +997,9 @@ struct Factorizer {
999997 }
1000998 }
1001999 if (num != 1U ) {
1002- // The number was not fully factored,
1003- // because it is not smooth.
1004- return std::vector< size_t >() ;
1000+ // The number was not fully factored, because it is not smooth.
1001+ // Make it smooth, by dividing out the remaining non- smooth factors!
1002+ (*numPtr) /= num ;
10051003 }
10061004
10071005 // This number is necessarily a smooth perfect square.
0 commit comments