If a congruence involves an unknown , we can try to solve it, just like an equation — but there will never be a unique solution, as multiples of the modulus may always be added without changing anything; the best we can hope for is to express the solution in the form ‘‘’’ for some . A congruence is easy: adding to both sides (as we may by Lemma 5.1.7) gives the solution as .
A congruence is more subtle, however: there may be no solutions at all; or if there are any, they may involve a modulus other than .
has no solutions, since any number is even, whereas any number congruent to modulo is odd.
has both and as solutions (as and ); since , the solution cannot be of the form ‘‘’’.
Example 5.2.1(i) raises the question: when does the congruence have solutions? The answer is as follows.
Let and . The congruence has solutions if and only if .
The congruence has solutions because and (in fact is one solution). On the other hand, the congruence does not have any solutions because and
Proof. Set .
‘‘’’. Suppose that the congruence has solutions; choose one, say , so that . We can then write for some , and thus . Since and , we conclude that
‘‘’’. Conversely, suppose that , say for some . By Theorem 4.2.17, we can write for some , and therefore
so the congruence has solutions, because is one.
In fact the second half of the proof of Theorem 5.2.2 gives us more than we have stated: whenever solutions exist, it tells us how to find one explicitly. We formally record this finding as follows.
Suppose that and satisfy , and choose such that . Then is a solution to the congruence .
We now turn our attention to the problem of finding all solutions to a given congruence (under the assumption that solutions exist, of course). We refer to this as finding the complete solution to the congruence. In this context, a specific number which satisfies the congruence is called a particular solution.
We begin by considering the case where and are coprime.
Let , and , and suppose that and are coprime. If , then .
Proof. By assumption, divides . As and are coprime, this implies that divides by Theorem 4.4.8, and the result follows.
Let , and , and suppose that and are coprime. Then there are such that , and the complete solution to the congruence is given by .
Consider the congruence ; in the notation of Theorem 5.2.6, we have , and . Prime factorization shows that and are coprime, so that divides , and therefore solutions exist. It is easy to see that (if not, use the Euclidean algorithm!), so that we can choose and . Hence we conclude that the congruence has the complete solution
(We can easily check that is a solution: .) Since , we can (and should!) simplify this answer to .
Proof. Set . Since and are coprime, Corollary 5.2.4 shows that is a solution to the congruence, that is, .
We must show that an integer satisfies if and only if .
‘‘’’. Suppose that . Lemma 5.1.7 shows that , so that by Lemma 5.1.9. Lemma 5.2.5 allows us to cancel because and are coprime, and hence we have .
We can now solve completely any congruence of the form provided that and are coprime. Thus all that remains is to show how to reduce a general congruence which has solutions to one in which and are coprime. This is easily achieved using the following result.
Suppose that and . Then if and only if .
Proof. By Proposition 5.1.3(b), means that for some , while means that for some These two statements are clearly equivalent (divide/multiply by ).
Decide whether or not the congruence has solutions; if solutions exist, find the complete solution.
Solution. By prime factorization (or the Euclidean algorithm), we find . Since , solutions exist by Theorem 5.2.2. To find the complete solution, we apply Lemma 5.2.8: an integer satisfies if and only if
we saw above that this congruence has the complete solution
As a check, we verify that satisfies the original congruence:
Decide whether or not the congruence has solutions; if solutions exist, find the complete solution.
Solution. By the Euclidean algorithm, we find
and | |||||||
Since , solutions exist by Theorem 5.2.2. To find the complete solution, we apply Lemma 5.2.8: an integer satisfies if and only if
(5.2.1) |
where
so in particular and are coprime (but we know that already, by Corollary 4.4.6). Hence the complete solution to the right-hand congruence in (5.2.1) is given by
As a check, we verify that solves the original congruence: