且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

用于素数生成的动态筛选算法

更新时间:2023-02-26 18:09:02

要生成M个质数,您需要上升到大约M logM。请参见第n个质数的近似值。 = http://en.wikipedia.org/wiki/Prime_number_theorem rel = nofollow>此Wikipedia文章关于素数定理。为了安全起见,您可能需要高估-例如N = M(log M +1)。

To generate M primes, you need to go up to about M log M. See Approximations for the nth prime number in this Wikipedia article about the Prime Number Theorem. To be on the safe side, you might want to overestimate -- say N = M (log M + 1).

编辑后添加:正如David Hammen指出的那样,这种高估并不总是足够好。 Wikipedia文章将M(log M + log log M)作为M> = 6的安全上限。

Edited to add: As David Hammen points out, this overestimate is not always good enough. The Wikipedia article gives M (log M + log log M) as a safe upper bound for M >= 6.