Which is the fastest algorithm to find prime numbers?

后端 未结 14 1600
情深已故
情深已故 2020-11-22 06:49

Which is the fastest algorithm to find out prime numbers using C++? I have used sieve\'s algorithm but I still want it to be faster!

14条回答
  •  Happy的楠姐
    2020-11-22 07:08

    If it has to be really fast you can include a list of primes:
    http://www.bigprimes.net/archive/prime/

    If you just have to know if a certain number is a prime number, there are various prime tests listed on wikipedia. They are probably the fastest method to determine if large numbers are primes, especially because they can tell you if a number is not a prime.

提交回复
热议问题