Z+ = nonzero elements of *Z*_{n} = {1, 2, , n-1}.

By Fermat's Theorem, if n is prime, then for every .

If some a violates, then n is composite.

- Pseudo test tries formula for a=2. If satisfied, declare n prime.
- Does not always work, but the numbers errantly declared prime (base-a pseudoprimes) are rare.
- Carmichael Numbers are composites that satisfy formula for all . Very rare.
- Miller-Rabin randomized primality test overcomes this deficiency in the pseudo test (tries random ``a''s).