Modulo Calculator
Result
About Modulo Operation
The modulo operation (denoted by %) finds the remainder after division of one number by another. It's a fundamental operation in mathematics and computer science.
Formula:
a mod m = r, where a = q × m + r and 0 ≤ r < m
Properties:
- If a mod m = r, then a = q × m + r for some integer q
- 0 ≤ r < m (remainder is always non-negative and less than the divisor)
- If a is negative, the result is still non-negative
- If m is negative, the result is the same as with positive m
Examples:
Expression | Result | Explanation |
---|---|---|
17 mod 5 | 2 | 17 = 3 × 5 + 2 |
-17 mod 5 | 3 | -17 = -4 × 5 + 3 |
17 mod -5 | 2 | 17 = -3 × -5 + 2 |
Applications:
- Finding even/odd numbers (n mod 2)
- Cyclic operations and wraparound
- Hash functions and data structures
- Cryptography and number theory
- Time calculations (e.g., 24-hour clock)
Tips:
- Always ensure the divisor is not zero
- For negative numbers, the result is always non-negative
- Modulo is useful for cyclic operations and wraparound
- In programming, modulo is often used for array indexing
Advertisement Space