

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
This document clarifies the distinction between using the mod operator as a binary operator and as a congruence relation in mathematics. It explains the notation and provides examples of both applications. Useful for students and researchers in mathematics and computer science.
Typology: Exercises
1 / 3
This page cannot be seen from the preview
Don't miss anything!


The operator mod is used in this book, and in the literature, in two different ways, as a binary operator and as a congruence relation. This appendix explains the distinction and precisely defines the notation used in this book regarding parentheses. This notation is common but, unfortunately, not universal.
If a is an integer and n is a nonzero integer, we define a mod n to be the remainder when a is divided by n. The integer n is called the modulus , and the remainder is called the residue. Thus, for any integer a , we can always write: a = a / n × n + ( a mod n ) Formally, we define the operator mod as follows: a mod n = a – a / n × n for n ≠ 0 As a binary operation, mod takes two integer arguments and returns the remainder. For example, 7 mod 3 = 1. The arguments may be integers, integer variables, or integer variable expressions. For example, all of the following are valid, with the obvious meanings: 7 mod 3 7 mod m x mod 3 x mod m ( x^2 + y + 1) mod (2 m + n )
where all of the variables are integers. In each case, the left-hand term is divided by the right- hand term, and the resulting value is the remainder. Note that if either the left- or right-hand argument is an expression, the expression is parenthesized. The operator mod is not inside parentheses. In fact, the mod operation also works if the two arguments are arbitrary real numbers, not just integers. In this book, we are concerned only with the integer operation.
As a congruence relation, mod expresses that two arguments have the same remainder with respect to a given modulus. For example 7 ≡ 4 (mod 3) expresses the fact that both 7 and 4 have a remainder of 1 when divided by 3. The following two expressions are equivalent: a ≡ b (mod m ) ⇔ a mod m = b mod m Another way of expressing it is to say that the expression a ≡ b (mod m ) is the same as saying that a – b is an integral multiple of m. Again, all the arguments may be integers, integer variables, or integer variable expressions. For example, all of the following are valid, with the obvious meanings: 7 ≡ 4 (mod 3 ) x ≡ y (mod m) ( x^2 + y + 1) ≡ ( a + 1) (mod [ m + n ] ) where all of the variables are integers. Two conventions are used. The congruence sign is ≡. The modulus for the relation is defined by placing the mod operator followed by the modulus in parentheses.