Why do we choose random bases for the Fermat primality test?

109 Views Asked by At

As in title, why do people usually choose random bases for the Fermat primality test as opposed to just using bases $2, 3, 4, ...$ in succession? Say we want to know if $N$ is prime/Carmichael or composite (with no preference for prime or Carmichael). We try a bunch of bases $a$ and calculate $a^{N - 1} \mod N$. Is there some structural thing that makes small bases not work as well?

1

There are 1 best solutions below

1
On BEST ANSWER

When $a$ is chosen randomly (and $N$ is odd), instead of working in $\Bbb{Z}/N\Bbb{Z}^\times$ we can do our reasonning in the product of cyclic groups $\prod_{p^k\| N}\Bbb{Z/p^{k-1}(p-1) Z}$, choosing some $a$ randomly in this group,

whereas when $a$ is constrained to be in a small interval $[2,A]$, we have no idea of what kind of elements it gives in $\prod_{p^k\| N}\Bbb{Z/p^{k-1}(p-1) Z}$ thus we have no clue of what is the probability that it is a false Fermat witness.