Mathematical Preliminaries for COMP372 Algorithms
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
Your grade is: __