Lagrange theorem for polynomial congruences says that a nonzero polynomial of degree over the finite field has at most roots. To prove it, use mathematical induction on . A constant nonzero polynomial has no roots. If , polynomial division in the field gives with . Every root other than is a root of , so the induction hypothesis gives at most roots.
Every nonzero residue class modulo has a unique multiplicative inverse. In the product , pair each class with its inverse. The unpaired classes satisfy , hence . By the theorem these are exactly and , and therefore
This is Wilson theorem.
Now write . By Fermat's little theorem, every nonzero class is a root of
The second factor has degree and hence at most roots. Since their union contains all nonzero classes, has at least roots; Lagrange's theorem gives at most . Thus has exactly solutions.
The Lagrange theorem for polynomial congruences says that if is prime and has degree with at least one coefficient not divisible by , then
has at most incongruent solutions modulo .
The Chinese remainder theorem states that for pairwise coprime , every system
has exactly one solution modulo . For two moduli, choose with by Bezout identity. Then
is congruent to modulo and to modulo . If are two solutions, both and divide ; coprimality makes divide . This proves existence and uniqueness for two factors, and induction proves the general statement.
Now
and , so is a solution. For , one has , so no such positive integer can satisfy the congruence. Hence the smallest is
Modulo , the roots are respectively
Each list has three elements, and the Chinese remainder theorem combines the choices independently. Therefore the number of solutions with is