Naturally, for bool isprime(number)
there would be a data structure I could query.
I define the best algorithm, to be the algorithm that pr
The best method, in my opinion, is to use what's gone before.
There are lists of the first N
primes on the internet with N
stretching up to at least fifty million. Download the files and use them, it's likely to be much faster than any other method you'll come up with.
If you want an actual algorithm for making your own primes, Wikipedia has all sorts of good stuff on primes here, including links to the various methods for doing it, and prime testing here, both probability-based and fast-deterministic methods.
There should be a concerted effort to find the first billion (or even more) primes and get them published on the net somewhere so people can stop doing this same job over and over and over and ... :-)