I agree with the comments of the previous colleagues, but could not avoid mentioning the coincidence that the first author of the first proven deterministic primality test in polynomial time* - the AKS primality test - seems to have your name, except for one letter: "Agrawal", from the famous 2002 Agrawal–Kayal–Saxena primality test.
I agree with the comments of the previous colleagues, but could not avoid mentioning the coincidence that the first author of the first proven deterministic primality test in polynomial time* - the AKS primality test - seems to have your name, except for one letter: "Agrawal", from the famous 2002 Agrawal–Kayal–Saxena primality test.
There is not indeed a data structure for you to query. If you have many numbers to test, you should probably run a probabilistic test since those are faster, and then follow it up with a deterministic test to make sure the number is prime. You have to know that the math behind the fastest algorithms is not for the faint of heart.
"best algorithm" probably is difficult to pinpoint to because many algorithms are improvements of some previously thought the best algorithm. Are you looking at complexity of the algorithm (i.e. which one requires less computation or which one requires less space) or are you just looking for an algorithm which can tell you that a particular integer is a prime the fastest?
the probability falls when the number increases, so there is still no accurate to describe it without calculating every figure, but you can use this as the first test because it reduces the universe of numbers.