Fermat primality test (source code)

= Fermat primality test
{c}
{wiki}

The Fermat test looks for a coprime base $a$ with $a^{N-1}\not\equiv1\pmod N$. Such a witness proves compositeness by the <Fermat little theorem>, but <Carmichael numbers> pass for every coprime base.