Fix for nSievePercentage = 100 in EstimateCandidatePrimeProbability().

master
Mikael Hirki 2013-08-01 09:33:46 +03:00
parent abd1c37bc4
commit d2812fa206
1 changed files with 1 additions and 1 deletions

View File

@ -1184,7 +1184,7 @@ double EstimateCandidatePrimeProbability(unsigned int nPrimorialMultiplier)
// statistically independent after running the sieve, which might not be
// true, but nontheless it's a reasonable model of the chances of finding
// prime chains.
const unsigned int nSieveWeaveOptimalPrime = vPrimes[(unsigned int) ((uint64) nSievePercentage * vPrimes.size() / 100)];
const unsigned int nSieveWeaveOptimalPrime = vPrimes[(unsigned int) ((uint64) nSievePercentage * vPrimes.size() / 100) - 1];
const unsigned int nAverageCandidateMultiplier = nSieveSize / 2;
return (1.781072 * log((double)std::max(1u, nSieveWeaveOptimalPrime)) / (256.0 * log(2.0) + (double) nPrimorialMultiplier + log(nAverageCandidateMultiplier)));
}