Fast Algorithm to find number of primes between two numbers

前端 未结 5 2018
后悔当初
后悔当初 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:35

    The fastest method that I know would be to eliminate all of the known non-primes (even numbers, all the numbers with divisers lower than the start number in the range, etc) as fast as you can, then iterate over the rest and use something like the Euclidean algorithm to determine if that number is a prime.

提交回复
热议问题