Modulo Calculator
Calculate modulo (remainder) and check divisibility
Remainder
—
Related Calculators
Frequently Asked Questions
What is modulo (mod)?
Modulo gives the remainder after division. 17 mod 5 = 2 because 17 = 5 × 3 + 2. The remainder is always in the range [0, divisor-1]. In programming: Python uses %, JavaScript uses %. Note: programming languages may handle negative numbers differently.
How is modulo used in programming?
Even/odd check: n%2==0 means even. Wrapping around: array index i%length keeps within bounds. Cyclic operations: day-of-week = (day+7)%7. Hashing: hash%tableSize. Last n digits: number%10^n. Scheduling: task runs every k units when t%k==0.
What is the difference between modulo and remainder?
For positive numbers, they are the same. For negative numbers: In math, modulo is always in [0, b-1]: -7 mod 3 = 2 (because -7 = 3 × -3 + 2). In many programming languages, the % operator gives the C-style remainder with the same sign as the dividend: -7 % 3 = -1 in C/Java/JavaScript.
What is modular arithmetic?
Modular arithmetic (clock arithmetic) wraps numbers around a fixed modulus. On a 12-hour clock: 11 + 3 = 14 ≡ 2 (mod 12). Key operations: (a+b) mod n, (a×b) mod n. Used in cryptography (RSA encryption), computer science, and number theory.
How do I check divisibility with modulo?
a is divisible by b if a mod b == 0. Examples: 20 mod 4 = 0 (divisible). 21 mod 4 = 1 (not divisible). Divisibility rules: mod 2 for even/odd, mod 9 for sum-of-digits rule, mod 10 for last digit. Used in leap year: year%4==0 (with exceptions for century years).
Divisibility Rules via Modulo
| Divisor | Rule |
|---|---|
| 2 | Last digit even (0,2,4,6,8) |
| 3 | Sum of digits divisible by 3 |
| 4 | Last 2 digits divisible by 4 |
| 5 | Last digit 0 or 5 |
| 9 | Sum of digits divisible by 9 |
| 10 | Last digit is 0 |