Modular arithmetic/Intermediate
Given integers , , and , with , we say that is congruent to modulo , or (mod ), if the difference is divisible by .
For a given positive integer , the relation (mod ) is an equivalence relation on the set of integers. This relation gives rise to an algebraic structure called the integers modulo (usually known as "the integers mod ," or for short). This structure gives us a useful tool for solving a wide range of number-theoretic problems, including finding solutions to Diophantine equations, testing whether certain large numbers are prime, and even some problems in cryptology.
Arithmetic Modulo n
Useful Facts
Consider four integers and a positive integer such that and . In modular arithmetic, the following identities hold:
- Addition: .
- Subtraction: .
- Multiplication: .
- Division: , where is a positive integer that divides and .
- Exponentiation: where is a positive integer.
For examples, see Introduction to modular arithmetic.
Miscellany
The binary operation "mod"
Related to the concept of congruence, mod is the binary operation mod , which is used often in computer programming.
Recall that, by the Division Algorithm, given any two integers and , with , we can find integers and , with , such that . The number is called the quotient, and the number is called the remainder. The operation mod returns the value of the remainder . For example:
mod , since .
mod , since .
mod , since .
Observe that if mod , then we also have (mod ).
An example exercise with modular arithmetic:
Problem:
Let
be a nine-digit positive integer (each digit not necessarily distinct). Consider
,
another nine-digit positive integer with the property that each digit ei when substituted for di makes the modified D divisible by 7. Let
be a third nine-digit positive integer with the same relation to E as E has to D.
Prove that every is divisible by 7.
Solution:
Any positive integer can be expressed .
Since 10=3 mod 7, and since it holds that if a=b mod c then mod c, then D can be expressed much more simply mod 7; that is, = x mod 7.
Each number in E must make the modified D equal 0 mod 7, so for each , , where c is the coefficient of and k is an element of {-2,-1,0,1,2}. The patient reader should feel free to verify that this makes D = 0 mod 7.
In terms of terms, then, we find each .
Then mod 7 can be expressed mod 7 = (9x)- x = 8x = x mod 7. (note that the 7s, which do not change the mod value, have been eliminated).
Each number in F must make the modified E equal 0 mod 7, so for each , .
By design and selection of k, all are integers, and is always an integer because it is the difference of two integers.
is a member of the set {1, 2, 3}. Since no divides 7, 7 may be factored and is the product of two integers.
Let then 7A mod 7 = 0 mod 7 for all , QED.