The fact that there are only a finite number of essentially different numbers in arithmetic to a modulus m means that there are algebraic relations which are satisfied by every number in that arithmetic. There is nothing analogous to these relations in ordinary arithmetic.

Suppose we take any number x and consider its powers . Since there are only a finite number of possibilities of these to the modulus m, we must eventually come to one which we have met before, say , where . If x is relatively prime to m, the factor can be cancelled, and it follows that , where . Hence, every number x which is relatively prime to m satisfies some congruence of this form. The least exponent l for which will be called the order of x to the modulus m. If x is 1, its order is obviously 1. To illustrate the definition, let us calculate the orders of a few numbers to the modulus 11. The powers of 2, taken to the modulus 11, are

2, 4, 8, 5, 10, 9, 7, 3, 6, 1, 2, 4,

Each one is twice the preceding one, with 11 or a multiple of 11 subtracted where necessary to make the result less than 11. The first power of 2 which is is , and so the order of is 10. As another example, take the powers of 3:

3, 9, 5, 4, 1, 3, 9,

The first power of 3 which is equivalent to 1 is , so the order of is 5. It will be found that the order of 4 is again 5, and so also is that of 5.

It will be seen that the successive powers of x are periodic; when we have reached the first number l for which , then and the previous cycle is repeated. It is plain that if and only if n is a multiple of the order of x. In the last example, if and only if n is a multiple of 5. This remains valid if n is 0 (since 3^{0} = 1), and it remains valid also for negative exponents, provided , is interpreted as a fraction (mod 11) in the way explained earlier (an earlier blog article).

In fact, the negative powers of 3 (mod 11) are obtained by prolonging the series backwards, and the table of powers of 3 to the modulus 11 is:

Fermat discovered that if the modulus is a prime, say p, then every integer x not congruent to 0 satisfies

….call this as equation A.

In view of what we have seen above, this is equivalent to saying that the order of any number is a divisor of . The result A was mentioned by Fermat in a letter to Frenicle de Bessy of 18 October 1640, in which he also stated that he had a proof. But, as with most of Fermat’s discoveries, the proof was not published or preserved. The first known proof seems to have been given by Leibniz (1646-1716). He proved that , which is equivalent to A, by writing x as a sum of x units (assuming x positive), and then expanding by the multinomial theorem. The terms give x, and the coefficients of all the other terms are easily proved to be divisible by p.

Quite a different proof was given by Ivory in 1806. If , the integers

are congruent in some order to the numbers

.

In fact, each of these sets constitutes a complete set of residues except that 0 (zero) has been omitted from each. Since the two sets are congruent, their products are congruent, and so

Cancelling the factors 2, 3, ….(p-1), as is permissible we obtain the above relation A.

One merit of this proof is that it can be extended so as to apply to the more general case when the modulus is no longer a prime.

The generalization of the result A to any modulus was first given by Euler in 1760. To formulate it, we must begin by considering how many numbers in the set 0, 1, 2, …, (m-1) are relatively prime to m. Denote this number by . When m is a prime, all the numbers in the set except 0 (zero) are relatively prime to m, so that for any prime p. Euler’s generalization of Fermat’s theorem is that for any modulus m,

…relation B

provided only that x is relatively prime to m.

To prove this, it is only necessary to modify Ivory’s method by omitting from the numbers not only the number 0, but all numbers which are not relatively prime to m. These remain numbers, say

, where .

Then, the numbers

are congruent, in some order, to the previous numbers, and on multiplying and cancelling (as is permissible) we obtain , which is relation B.

To illustrate this proof, take . The numbers less than 20 and relatively prime to 20 are :

1, 3, 7, 9, 11, 13, 17, 19.

So that . If we multiply these by any number x which is relatively prime to 20, the new numbers are congruent to the original numbers in some other order. For example, if x is 3, the new numbers are congruent respectively to

It often happens that for the purposes of a particular calculation, two numbers which differ by a multiple of some fixed number are equivalent, in the sense that they produce the same result. For example, the value of depends only on whether n is odd or even, so that two values of n which differ by a multiple of 2 give the same result. Or again, if we are concerned only with the last digit of a number, then for that purpose two numbers which differ by a multiple of 10 are effectively the same.

The congruence notation, introduced by Gauss, serves to express in a convenient form the fact that the two integers a and b differ by a multiple of a fixed natural number m. We say that a is congruent to b with respect to the modulus m, or in symbols,

The meaning of this, then, is simply that is divisible by m. The notation facilitates calculations in which numbers differing by a multiple of m are effectively the same, by stressing the analogy between congruence and equality. Congruence, in fact, means “equality except for the addition of some multiple of m”.

A few examples of valid congruences are :

; ;

A congruence to the modulus 1 is always valid, whatever the two numbers may be, since every number is a multiple of 1. Two numbers are congruent with respect to the modulus 2 if they are of the same parity, that is, both even or both odd.

Two congruences can be added, subtracted or multiplied together, in just the same way as two equations, provided all the congruences have the same modulus. If

and

then:

The first two of these statements are immediate: for example, is a multiple of m because and are both multiples of m. The third is not quite so immediate because , and is a multiple of m. Next, , for a similar reason. Hence, .

A congruence can always be multiplied throughout by any integer; if the10n . Indeed this is a special case of the third result above, where and are both k. But, it is not always legitimate to cancel a factor from a congruence. For example, , but it is not permissible to cancel the factor 6 from the numbers 42 and 12, since this would give the false result . The reason is obvious: the first congruence states that is a multiple of 10, but this does not imply that is a multiple of 10. The cancellation of a factor from a congruence is legitimate if the factor is relatively prime to the modulus. For, let the given congruence be , where is the factor to be cancelled, and we suppose that a is relatively prime to m. The congruence states that is divisible by m, and hence, is divisible by m.

An illustration of the use of congruences is provided by the well-known rules for the divisibility of a number by 3 or 9 or 11. The usual representation of a number n by digits in the scale of 10 is really a representation of n in the form

where a, b, c, … are the digits of the number, read from right to left, so that a is the number of units, b the number of tens, and so on. Since , we have also , and , and so on. Hence, it follows from the above representation of n that

In other words, any number n differs from the sum of its digits by a multiple of 9, and in particular n is divisible by 9 if and only if the sum of its digits is divisible by 9. The same applies with 3 in place of 9 throughout.

The rule for 11 is based on the fact that so that , and so on. Hence,

It follows that n is divisible by 11 if and only if is divisible by 11. For example, to test the divisibility of 958 by 11 we form 1-8+5-9, or -11. Since this is divisible by 11, so is 9581.