Super Calculator logoSuper Calculator

Modulo Calculator

Calculate modulo (remainder) and check divisibility

Results are estimates for informational purposes only — not professional financial, medical, or legal advice. See how we build and verify our 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

DivisorRule
2Last digit even (0,2,4,6,8)
3Sum of digits divisible by 3
4Last 2 digits divisible by 4
5Last digit 0 or 5
9Sum of digits divisible by 9
10Last digit is 0

Modulo in Programming

n%2==0 → even number
i%arr.length → circular array indexing
(hour+offset)%24 → time zone wrapping
id%shards → database sharding
turn%players → whose turn next
n%10 → last digit of any integer