Modulo Calculator (a mod n)
a mod n: remainder of a divided by n. Always non-negative for positive n.
Result
a mod n
2
17 = 3 Ć 5 + 2.
- a17
- n5
- a mod n (math)always 0 to nā12
- a % n (JS)sign follows a2
- Quotient (trunc)3
- Quotient (floor)3
- Verify3 Ć 5 + 2 = 17
Step-by-step
- a / n = 17 / 5 = 3.4 ā floor = 3.
- Math mod = a ā floor(a/n) Ć n = 17 ā 15 = 2.
- JS and math agree (a ā„ 0).
How to use this calculator
- Enter a and n.
- Read mathematical mod (always 0..nā1) and JS-style mod (signed).
About this calculator
Modulo (a mod n) returns the remainder when a is divided by n. For positive operands: 17 mod 5 = 2 (since 17 = 3 Ć 5 + 2). For negative dividends, conventions differ: math mod is always non-negative (ā7 mod 5 = 3); programmer's remainder follows sign of dividend (-7 % 5 = -2 in JS/C/Java). Used in cryptography, hashing, cyclic structures (clocks, calendars), and array indexing.
Frequently asked
Math mod follows Euclidean division (always non-negative). C/Java/JS "remainder" follows sign of dividend. Python's % matches math mod.
Related calculators
GCD (Greatest Common Divisor) Calculator
Euclidean algorithm: gcd(a,b) = gcd(b, a mod b). Supports 2-6 integers.
LCM (Least Common Multiple) Calculator
lcm(a,b) = |a Ć b| / gcd(a,b). Smallest number that both a and b divide evenly.
Prime Number Checker
Is n prime? Trial division up to ān; identifies smallest divisor and nearest primes if composite.
Base Converter (Bin/Oct/Dec/Hex)
Convert any integer between binary (2), octal (8), decimal (10), and hexadecimal (16).
Big-O Time Complexity Calculator
Operations vs. n for common Big-O classes: O(1), O(log n), O(n), O(n log n), O(n²), O(2āæ).
Scientific Notation Converter
Convert decimal ā scientific notation. Standard form a Ć 10^b with 1 ⤠|a| < 10.