在浏览了一些SO 帖子后,我发现埃拉托色尼筛法是生成素数的最佳且最快的方法。
我想生成两个数字之间的素数,例如a和b。
a
b
AFAIK,在 Sieve 方法中,空间复杂度为O(b)。
PS:我写的是Big-O而不是Theta,因为我不知道空间要求是否可以减少。
我们可以降低埃拉托斯特尼筛法的空间复杂度吗?
algorithm primes sieve-of-eratosthenes space-complexity data-structures
algorithm ×1
data-structures ×1
primes ×1
sieve-of-eratosthenes ×1
space-complexity ×1