Fast Algorithm to find number of primes between two numbers

前端 未结 5 2032
后悔当初
后悔当初 2021-02-04 14:57

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 op

5条回答
  •  广开言路
    2021-02-04 15:31

    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.

    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.

    This is based on the Prime Number Theorem which says that the Prime Counting Function is asymptotic to the Logarithmic Integral.

提交回复
热议问题