快速算法发现的素数的两个数字之间的数素数、算法、两个、快速

2023-09-11 22:50:16 作者:入戏半分笑

我的问题简化为查找两个给定numbers.I之间质数的数目可能有一系列大如 1(1000)!,因此我需要一些数学优化。

My problem reduces to finding the number of primes between two given numbers.I could have a range as big as 1 to (1000)! and hence I am need of some mathematical optimizations.

显然,筛的方法是在这种情况下太慢。有可应用任何数学优化 - 例如像,采取这种大空间的一个小的子集,并进行推断有关号码的其余部分。

Clearly the sieve method would be too slow in this case. Is there any mathematical optimization that can be applied - like for instance, taking a smaller subset of this large space and making inferences about the rest of the numbers.

PS:这肯定看起来像我可能已经走进了死胡同 - 但所有我正在寻找一些优化那些可能帮助解决这个问题。而且,我只想找一个单线程的方法。

P.S: It definitely looks like I might have reached a dead end - but all that I am looking for are some optimizations that could possibly help solve this. And also, I am only looking for a single-threaded approach.

编辑:一种方法我一直在想,可以解决很多的大素数相关的问题 - 是专人维护质数的全局表,并使其可用于查找。乡亲在PrimeGrid项目能够实现这一有益的贡献。

One approach I have been thinking and can solve a lot of large prime number related problems - is for someone to maintain a global table of primes and make it available for lookup. Folks at the PrimeGrid project can contribute usefully towards this.

推荐答案

既然你想去高达 1000!(阶乘)。您将无法获得与目前的技术目前已知的方法精确的结果。

Since you want to go as high as 1000! (factorial). You will not be able to get exact results with currently known methods on current technology.

借助总理计数功能只被准确地评估了一把价值高达 10 ^ 24 。所以没有办法,你就可以按 1000!

The Prime Counting Function has only been evaluated exactly for a handful of values up to 10^24. So no way you'll be able to hit 1000!.

不过既然你提到比近似可能是罚款,你可以使用数积分作为一个近似总理计数功能。

But since you mention than an approximation may be fine, you can use the Logarithmic Integral as an approximation to the Prime Counting Function.

这是基于素数定理它说,在总理计数功能是渐进的对数积分