Better. Return true if the number is in a stored list of known primes, otherwise return false right away.
But then, start a separate thread with an actual verification algorithm.
When the verification is done, if it was actually a prime number, you just crash the program with a WasActuallyPrime exception.
Better. Return true if the number is in a stored list of known primes, otherwise return false right away. But then, start a separate thread with an actual verification algorithm. When the verification is done, if it was actually a prime number, you just crash the program with a WasActuallyPrime exception.