... LIVE
Enter a valid integer.
The number being divided
Enter a non-zero integer.
The number to divide by (cannot be zero)
Common Examples
Remainder (a mod n)

Sources & Methodology

Modulo calculations follow the standard Euclidean division definition as specified in ISO 80000-2 mathematical notation standards.
📖
Khan Academy — Modular Arithmetic
Mathematical foundation and definition of the modulo operation used in this calculator
💻
Modular Arithmetic — Mathematical Reference
Formal mathematical definition of modulo operation, congruence, and modular arithmetic properties
Methodology: For positive integers, a mod n = a − n × floor(a/n). This calculator uses JavaScript's built-in modulo behavior adjusted for the mathematical convention: for any integers a and n (n ≠ 0), the result is always non-negative when n is positive. Formula: remainder = ((a % n) + n) % n ensures correct results for all integer inputs including negatives.

⏱ Last reviewed: April 2026

How to Calculate Modulo (Mod)

The modulo operation finds the remainder after integer division. Written as a mod n or a % n, it asks: "When I divide a by n, what is left over?" The result is always between 0 and n−1 for positive n.

The Modulo Formula
a mod n = a − n × floor(a ÷ n)
Example: 17 mod 5
Step 1: floor(17 / 5) = floor(3.4) = 3 (quotient)
Step 2: 3 × 5 = 15
Step 3: 17 − 15 = 2 (remainder)
Verify: 5 × 3 + 2 = 15 + 2 = 17 ✓

Common Modulo Values Reference

ExpressionDivisionQuotientRemainder (mod)
10 mod 310 ÷ 331
17 mod 517 ÷ 532
100 mod 7100 ÷ 7142
256 mod 16256 ÷ 16160
365 mod 7365 ÷ 7521
1000 mod 91000 ÷ 91111

Modulo in Programming (% Operator)

In most programming languages, the % operator performs modulo. It is one of the most frequently used operations in software development. The most common use is checking if a number is even or odd: n % 2 == 0 means even, n % 2 == 1 means odd. Other key uses include wrapping array indices, implementing hash tables, generating cyclic sequences, and solving calendar/time problems (e.g., "what day of the week is 100 days from now?" uses mod 7).

Modular Arithmetic Applications

Modular arithmetic forms the mathematical foundation for cryptography, computer science, and number theory. RSA encryption — the system that secures internet transactions — relies entirely on modular exponentiation. Checksums and error-detecting codes in barcodes, ISBN numbers, and credit card numbers all use modulo operations. The 12-hour clock is a real-world example of mod 12: 14:00 in 12-hour time is 14 mod 12 = 2 (2:00 PM).

💡 Quick Trick: If a mod n = 0, then a is evenly divisible by n. This is the divisibility test. For example, 256 mod 16 = 0 means 256 is perfectly divisible by 16. For any number a, a mod a = 0 and a mod 1 = 0 (every number is divisible by 1). Also, a mod a+1 = a always (since a+1 doesn't divide into a even once).
Frequently Asked Questions
Modulo (mod) is the remainder after integer division. For example, 17 mod 5 = 2 because 17 divided by 5 equals 3 with a remainder of 2. Written as a mod n or a % n, the result is always between 0 and n−1 for positive n.
17 mod 5 = 2. Divide 17 by 5: 5 goes into 17 three full times (15), with 2 remaining. Verify: (5 × 3) + 2 = 17. The remainder is 2.
10 mod 3 = 1. Divide 10 by 3: 3 goes into 10 three times (9), with 1 left over. Verify: (3 × 3) + 1 = 10. The remainder is 1.
The modulo formula is: a mod n = a − n × floor(a/n). For positive integers: remainder = dividend − divisor × quotient, where quotient = floor(dividend / divisor). For 23 mod 7: quotient = floor(23/7) = 3. Remainder = 23 − 7 × 3 = 23 − 21 = 2.
Modulo by zero (a mod 0) is undefined, just like division by zero. There is no valid mathematical result. This is treated as an error in both mathematics and all programming languages.
Modulo (%) is used to: check even/odd (n % 2 == 0 means even), wrap circular array indices, implement hash tables, generate repeating patterns, format time (minutes % 60, hours % 24), and compute checksums. It is one of the most essential operations in all of software development.
For positive numbers, they are the same. For negative numbers, the difference appears: mod keeps the sign of the divisor, while remainder keeps the sign of the dividend. For −7 mod 3: mathematical modulo = 2 (positive, sign of divisor 3), but C-style remainder = −1 (negative, sign of dividend −7). This calculator uses the mathematical (positive) convention.
100 mod 7 = 2. Divide 100 by 7: 7 goes into 100 fourteen times (98), with 2 remaining. Verify: (7 × 14) + 2 = 98 + 2 = 100. The remainder is 2.
A number n is even if n mod 2 = 0 and odd if n mod 2 = 1. This is the single most common use of modulo in programming. Examples: 14 mod 2 = 0 (even), 15 mod 2 = 1 (odd), 100 mod 2 = 0 (even), 999 mod 2 = 1 (odd).
15 mod 4 = 3. Divide 15 by 4: 4 goes into 15 three times (12), with 3 remaining. Verify: (4 × 3) + 3 = 12 + 3 = 15. The remainder is 3.
Related Calculators
Popular Calculators
🧮

Missing a Math Calculator?

Can’t find the math calculator you need? Tell us — we build new ones every week.