The Fermat-Euler theorem states that for an integer and a positive integer with ,
where the Euler totient function counts the residue classes coprime to . For , choose a reduced residue system . Multiplication by the unit modulo n preserves coprimality and is injective on these residue classes: implies , because has a multiplicative inverse modulo . It therefore permutes the reduced residue system, giving
The product is also a unit modulo n, so it can be cancelled. This proves the Fermat-Euler theorem. For every modular congruence is automatic; one may use .
For a prime number , the Euler totient function has value . Thus whenever . Multiplying by , and treating separately, gives the all-integer version of Fermat's little theorem:
Finally, Wilson theorem states that for every prime number , . Its converse is also true: an integer is prime exactly when . For the converse, any proper divisor would divide both and , contradicting that congruence.