Modulo Calculator – Find the Remainder of Division
Calculate the modulo or remainder of any division instantly with our free online modulo calculator. Essential for programming, number theory, and cryptography applications.
Understanding Modulo Operations
The modulo operation finds the remainder after division. When you divide a by n, you get a quotient and a remainder. The modulo operation returns just the remainder. For example, 17 / 5 = 3 remainder 2, so 17 mod 5 = 2.
Modulo is written as "a mod n" or "a % n" in programming. It's fundamental to computer science (array indexing, hash functions), cryptography (RSA, Diffie-Hellman), and everyday applications (checking if a number is even: n mod 2 = 0).
Modulo Formula
a mod n = a - n x floor(a/n)Or equivalently: a = q x n + r, where r = a mod n and 0 ≤ r < n
Key Property
The result is always between 0 and n-1 (inclusive). This makes modulo perfect for "wrapping" values into a fixed range.
Negative Numbers
For negative dividends, we add n until the result is positive. -17 mod 5 = 3 (not -2).
Worked Examples
Example 1: Simple Modulo
Example 2: Even Division
Example 3: Negative Dividend
Example 4: Clock Arithmetic
Quick Fact
The modulo operation is so important in computing that most programming languages have a dedicated operator for it (%). In Python, JavaScript, and C++, you write "a % n". The word "modulo" comes from Latin "modulus" meaning "measure" – it measures how far a number is from the nearest lower multiple.
Frequently Asked Questions
What's the difference between mod and remainder?
In mathematics, they're the same. In programming, the % operator may return negative results for negative inputs (called "truncated division"), while true modulo always returns positive. This calculator uses true mathematical modulo.
Can the divisor be negative?
Mathematically, we typically use positive divisors. If you need negative moduli, the sign convention varies. This calculator assumes positive divisors for consistent results.
What is modulo used for in programming?
Common uses include: checking even/odd (n % 2), wrapping array indices, implementing circular buffers, hash functions, generating random numbers in a range, and time calculations (seconds to minutes: s % 60).
How do I check if a number is divisible by n?
If a mod n = 0, then a is divisible by n. For example, 100 mod 5 = 0, so 100 is divisible by 5. This is faster than division for divisibility testing.
What does "congruent modulo n" mean?
Two numbers are congruent mod n if they have the same remainder. We write a ≡ b (mod n). For example, 17 ≡ 5 (mod 12) because both leave remainder 5 when divided by 12.
Why is my calculator showing a different result?
Some calculators and programming languages use truncated division for negative numbers, giving negative remainders. This calculator uses floored division, which always gives non-negative results – the mathematical standard.
Other Free Tools
Modular Arithmetic Calculator – Compute mod n Operations
Perform modular arithmetic operations including addition, subtraction, multiplication, and exponentiation under any modulus with our free online calculator.
Divisibility Checker – Test Divisibility Rules Instantly
Check if any number is divisible by another with our free online divisibility checker. Displays the relevant divisibility rule and provides instant yes or no results.
Divisibility Check 2–20 – Test Divisibility for All Numbers
Check divisibility by all integers from 2 to 20 with a single input using our free online divisibility tool. Displays divisibility results with the rules used for each.
Factor Calculator – Find All Factors of Any Integer
Find all factors of any integer instantly with our free online factor calculator. Lists every factor in ascending order – perfect for simplifying fractions and solving number theory problems.
GCD / HCF Calculator – Find Greatest Common Divisor Online
Calculate the GCD or HCF of two or more numbers instantly with our free online calculator. Uses the Euclidean algorithm to find the greatest common divisor with step-by-step solutions.
Binary Addition & Subtraction Calculator – Compute in Base 2
Add and subtract binary numbers step by step with our free online binary calculator. See each bit-by-bit operation clearly – perfect for computer science and digital electronics.
Bitwise Operations Calculator – Compute AND OR XOR NOT Shifts
Perform bitwise AND, OR, XOR, NOT, left shift, and right shift operations on integers with our free online bitwise calculator. See binary representations alongside results.
Euler's Totient Function Calculator – Compute φ(n) Online
Calculate Euler's totient function φ(n) for any integer with our free online calculator. Find the count of integers up to n that share no common factor with n.