Modulus Operator


The modulus (or mod) function returns the remainder of an integer division. That is, given \(m, n \)are integers, \(n\) mod \( m \) is the positive integer \(r\) such that \(n = qm + r \) for q an integer and \(0 \leq r < m \). Alternatively, the modulus is \( n - m \lfloor \frac {n}{m} \rfloor. \) The result of n mod m must be between 0 and \(m-1\). For example, 5 mod 3 = 2, -3 mod 5 = 2, 5 mod 5 = 0, 30 mod 4 = 2, 567 mod 5 = 2.

Self-Testing Quizzes


1. Which of the following is untrue? \(m, n, p \) are integers.

2. Which answer is impossible for the following problem given any integer \(x\)? \( x \)mod 4

3. Solve the following equation for \(x\): \(x\) mod 13 = 1

4. You have \(x \) apples. You want to equally split your apples into 7 baskets. What expression will tell you how many apples you have left over when you do this?

Your grade is: __