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
bool isprime(number)
According to wikipedia, the Sieve of Eratosthenes has complexity O(n * (log n) * (log log n)) and requires O(n) memory - so it's a pretty good place to start if you aren't testing for especially large numbers.