Let be an odd integer that is a composite number and write with odd. For a base coprime to , it is a strong pseudoprime whenThese are exactly the passing outcomes of the Miller-Rabin primality test for that base. The test computes by modular exponentiation and repeatedly squares it, looking for the permitted value before reaching exponent .
Every strong pseudoprime to a base is a Fermat pseudoprime to that base, by squaring a permitted congruence sufficiently many times. The converse fails. For , one has and , . Neither tested residue is , and the first is not , so base two detects compositeness even though .
New to topics? Read the docs here!