Skip to content

Commit

Permalink
Improve bounds
Browse files Browse the repository at this point in the history
  • Loading branch information
kimwalisch committed Jan 8, 2024
1 parent 5bae46c commit 9275650
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/nthPrime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,15 @@ uint64_t PrimeSieve::nthPrime(int64_t n, uint64_t start)
if (countApprox < n)
{
start = checkedAdd(start, 1);
uint64_t dist = (n - countApprox) * avgPrimeGap(start);
uint64_t dist = (n - countApprox) * avgPrimeGap(primeApprox);
uint64_t stop = checkedAdd(start, dist);
primesieve::iterator iter(start, stop);
for (int64_t i = countApprox; i < n; i++)
prime = iter.next_prime();
}
else // if (countApprox >= n)
{
uint64_t dist = (countApprox - n) * avgPrimeGap(start);
uint64_t dist = (countApprox - n) * avgPrimeGap(primeApprox);
uint64_t stop = checkedSub(start, dist);
primesieve::iterator iter(start, stop);
for (int64_t i = countApprox; i >= n; i--)
Expand Down

0 comments on commit 9275650

Please sign in to comment.