miun.logo

Integers and Congruences - Part V




An Application of Congruence

Example - ISBN

An interesting application of modulus is in ISBN. Maybe you have wondered why some books have an ISBN which ends in X? This is because the last digit is a check digit, calculated modulo 11, so an extra 'digit' is required to symbolise 10. How is the check digit calculated? It is a weighed sum, which means that each digit is multiplied by a fixed amount, and then the sum is taken. Suppose the ISBN is a1a2a3a4a5a6a7a8a9a10. Then the weighted sum is

a1+2a2+3a3+4a4+5a5+6a6+7a7+8a8+9a9+10a10.
The check digit a10 is calculated so that the weighted sum is congruent to 0 modulo 11. For example, the ISBN for Chetwynd and Diggle is 0340610476 so the weighted sum is 0+6+12+0+30+6+0+32+63+60 congruent 6+1-3+6-1-3-6 congruent 0 (mod 11). The advantage of this system is that if two digits are switched, or if one digit is incorrect, then the weighted sum is not congruent to 0 modulo 11, so we know there is an error somewhere although we do not know where or what it might be.

ax congruent b (mod n)

Next we are going to look at solving congruences, but first, let's consider the following situtation. Suppose

3x=3times4.

Then we cancel and get x=4. Nothing strange about that. Now let's look at the same thing, but this time, modulo 24:

3xcongruences3times4 (mod 24).

Is it true to say that xcongruences4? What if xcongruences12? Then

3times12 congruences 36congruences 12congruences 3times4 (mod 24).

This illustrates the fact that we must be very careful when cancelling while working with congruences. What you might wonder is if there is ever a time when we can cancel, and yes there is. We will come to that in a moment, after we have looked at the problem a bit more.

The Problem with Cancellation

Solve the equations

  1. 2 x congruent 8 (mod 4)
  2. 2 x congruent 3 (mod 4)
  3. 3 x congruent 2 (mod 4)

Solution

We use trial and error.

  1. Solutions are all integers x such that x congruent 0 (mod 4) or x congruent 2 (mod 4).
  2. There are no solutions.
  3. Solutions are all integers x such that x congruent 2 (mod 4).

We mentioned earlier than if ax congruent b (mod n), then we can write ax+nq=b for some integer q. From a result on diophantine equations, we know there is a solution to the equation ax+nq=b if and only if gcd(a,n) | b. This means that there is a solution to the congruence ax congruent b (mod n) if and only if gcd(a,n) | b.

In one of the examples above we got one solution from 0,1,2,3, and for another we got two solutions from 0,1,2,3. How do we know how many solutions we will get in this range, and how can we be sure we have found them all? Let's think about the diophantine equations again. We can write 2 x congruent 8 (mod 4) as 2x+4y=8 for some integer y. Now dividing by 2, we find that we get x+2y=4, that is x congruent 4 (mod 2). We might have thought that we could cancel to get x congruent 4 (mod 4), but that would have meant that we missed some possible values of x - all those congruent to 2 modulo 4. What we should do is divide by 2 thoughout: 2x/2 congruent 8/2 (mod 4/2). We summarise in the following result.

Result 1

If ax congruent ay (mod an), then x congruent y (mod n). end

Example

Find all values of x which satisfy the congruence 5x congruent 10 (mod 15).

As gcd(5,15)=5 is a factor of 10, there are solutions. We divide by 5 to get x congruent 2 (mod 3). This gives the following values for x (mod 15): 2,5,8,11,14.

Example

Find all values of x which satisfy the congruence 5x congruent 10 (mod 18).

As gcd(5,18)=1 is a factor of 10, there are solutions. We write the congruence as a diophantine equation: 5x+18y=10, where x and y are integers. By inspection, we see that a solution is given by x=-16 and y=5, and so the general solution is x=-16+18t, y=5-5t, for integers t. So x=-16+18t congruent -16 congruent 2(mod 18). end

Suppose we have ax congruent b (mod n) and we can find an integer r so that ar congruent 1 (mod n). Then we have rax congruent rb (mod n) and so x congruent rb (mod n) as ar congruent 1 (mod n). When does such an integer r exist? It exists if there is a solution to ar=1 + kn (integer k). There is a solution exactly when gcd(a,n) | 1, that is, when gcd(a,n)=1. This is summarised in the following result.

Result 2

Suppose ax congruent b (mod n), where gcd(a,n)=1. Then there is an integer r such that ar congruent 1 (mod n) and x congruent rb (mod n). end

One question which may arise is why, when we divided by a, did we divide everything by a:

ax congruent ay (mod an) implies xcongruent y (mod n)

but when we multiplied by r, we didn't multiply the modulus by r:

ax congruent b (mod n) implies rax congruent rb (mod n)?

The answer is as follows. First we write the congruence as a diophantine equation: ax congruent b (mod n) becomes ax+yn=b where y is an integer. Now we multiply by r to get rax+ryn=rb. Now as ryn is divisible by n, it is congruent to 0 modulo n. Hence rax congruent rb (mod n), as required.

Result 3

If a congruent b (mod mn) then a congruent b (mod n) and a congruent b (mod m)

Example

Find all values of x which satisfy the congruence 5x congruent 10 (mod 18).

As gcd(5,18)=1, there is an integer r such that 5r congruent 1 (mod 18). To find r, we either solve the diophantine equation 5r+18y=1, or we use trial and error. Take r=-7, to get 5(-7)=-35 congruent 1 (mod 18). Now we apply the result above to 5x congruent 10 (mod 18) to get x congruent -70 congruent 2 (mod 18).

Exercises

  1. Solve the following congruences where possible
    1. 4x congruent 5 (mod 9)
    2. 4x congruent 5 (mod 8)
    3. 4x congruent 8 (mod 12)
    4. 18x congruent 5 (mod 29)
  2. Determine the missing digit '?' in ISBN 91-518-?600-3.
  3. Decide which of the following are possible ISBN.
    1. 91-46-16515-0
    2. 91-46-16616-X
    3. 1-55615-104-7

Simultaneous Congruences

Now that we have covered solving individual congruences, we look at solving simultaneous congruences. Again, we rely on the techniques we developed earlier to solve diophantine equations.

Example

Consider x congruent 5 (mod 12) (*) and x congruent 7 (mod 16) (**). From result 3 above, we know that x congruent 5 (mod 12) implies x congruent 5 (mod 2) and x congruent 5 (mod 3) and x congruent 5 (mod 4) and x congruent 5 (mod 6). Similarly x congruent 7 (mod 16) implies x congruent 7 (mod 2) and x congruent 7 (mod 4) and x congruent 7 (mod 8). So x congruent 5congruent 1 (mod 4) and x congruent 7 congruent 3 (mod 4), which is a contradiction. Hence there are no solutions to this pair of simultaneous equations.

Example

Solve the simultaneous congruences x congruent 5 (mod 12) and x congruent 3 (mod 5).

Solution

Exercises

Solve the following pairs of simultaneous congruences, where possible.
  1. x congruent 5 (mod 9) and x congruent 7 (mod 13)
  2. x congruent 11 (mod 12) and x congruent 12 (mod 13)
  3. 2x congruent 5 (mod 12) and 5x congruent 7 (mod 13)
  4. x congruent 4 (mod 12) and x congruent 7 (mod 26)
  5. x congruent 5 (mod 12) and x congruent 7 (mod 26)

Sarah Norell
c/o Pia Heidtmann
© MITTUNIVERSITETET
Institutionen för Teknik, Fysik och Matematik
Mittuniversitetet
SE-851 70 SUNDSVALL
Sweden
Updated 060330.