# Bases for deterministic Miller-Rabin primality test

Miller-Rabin primality test can be made deterministic when the number $$n$$ is small, for example "if $$n < 2047$$, it is enough to test [with base] $$a = 2$$".

How are those bases found? By brute force? Say I pick an upper bound 2047 and test many different bases to see if any of them always returns correct primality outcomes?

• May be Finding primes & proving primality and the listed references help; especially Jaeschke's paper On strong pseudoprimes to several bases – gammatester Nov 30 '18 at 19:17
• The Wikipedia references are much more up to date than the primes.utm page, but certainly the basic references such as Jaeschke are worthwhile as they go into detail about the mathematics (not relying on exhaustive testing). For the efficient deterministic bases, somewhere past 32-bit they rely on the Feitsma/Galway enumeration of all base-2 strong pseudoprimes to get deterministic results for 64-bit inputs, which makes searches practical. – DanaJ Nov 30 '18 at 19:50

If the set is, for example {$$2,3$$}, the smallest counterexample is $$1373653$$ Hence we can say : If $$n<1373653$$ and $$n$$ is a strong Fermat-pseudoprime to bases $$2$$ and $$3$$ , then $$n$$ is prime.
The poulet-numbers are calculated upto a large limit, using these numbers we can (assuming that the set contains $$2$$) accelerate the search dramatically, but since the poulet-numbers were basically found by brute force, there is probably no better method to find the smallest counterexamples (or good base-combinations with a large smallest counter-example) than brute force.