Remainder of a ÷ b.
r = a − n × ⌊a / n⌋
The modulo operation finds the remainder r when dividend a is divided by divisor n. The standard mathematical definition uses the floor function to guarantee a non-negative result consistent with most programming languages and calculators:
r = a − n × ⌊a / n⌋
Equivalently, r is the unique integer satisfying:
where q is the integer quotient (floor division). This formulation ensures the remainder is always between 0 (inclusive) and |n| (exclusive).
Step 1 — Divide: 47 ÷ 6 = 7.8333… Step 2 — Floor: ⌊7.8333…⌋ = 7 (integer quotient q) Step 3 — Multiply: 6 × 7 = 42 Step 4 — Subtract: 47 − 42 = 5
Result: 47 mod 6 = **5** (Check: 6 × 7 + 5 = 42 + 5 = 47 ✓)
The result 5 means that when 47 is divided by 6, the division goes in evenly 7 times (producing 42) and leaves a leftover — or remainder — of 5. The remainder is always a whole number that is smaller than the absolute value of the divisor. If the remainder were 0, it would mean the dividend is exactly divisible by the divisor (i.e., 6 is a factor of 47 — which it is not in this case).
The modulo operation (often written as mod or %) is a basic arithmetic operation that returns the remainder after integer division. It is a close companion to regular division, but instead of returning the quotient, it returns what is left over.
Imagine a 12-hour clock. If it is currently 10 o'clock and you add 5 hours, you get 15, but clocks only go up to 12, so the actual time is 3 o'clock — because 15 mod 12 = 3. This cyclic "wrap-around" behaviour is the core idea behind modulo.
Behaviour with negative dividends or divisors varies by convention. The floored division convention (used here and in Python) always returns a non-negative remainder. For example, −7 mod 3 = 2, because −7 = 3 × (−3) + 2. Some languages (like C, Java, JavaScript) use truncated division, giving −7 % 3 = −1 instead.
n % 2).Divide the number by 2 using modulo. If n mod 2 = 0, the number is even. If n mod 2 = 1, the number is odd. For example, 14 mod 2 = 0 (even) and 15 mod 2 = 1 (odd).
Many day-of-week algorithms use modulo 7. For instance, if today is day 3 (Wednesday) and you want to know what day it will be in 100 days: (3 + 100) mod 7 = 103 mod 7 = 5, which corresponds to Friday (if 0 = Sunday).
The Euclidean algorithm for finding the GCD of two numbers is built entirely on the modulo operation: GCD(a, b) = GCD(b, a mod b), repeated until the remainder is 0. The last non-zero remainder is the GCD.
Modulo works identically for large numbers — just apply the formula r = a − n × ⌊a/n⌋. In cryptography, extremely large modulo operations (e.g., 2^1024 mod p) are computed efficiently using modular exponentiation algorithms.
Yes. 0 divided by any non-zero number n gives a quotient of 0 and a remainder of 0. So 0 mod n = 0 for all n ≠ 0.
In everyday math they are the same. However, in computing, 'remainder' sometimes refers to the result of truncated division (which can be negative), while 'mod' (using floored division) is always non-negative. For positive inputs the two are identical.
The classical modulo operation is defined for integers. Many calculators extend it to real numbers using the formula r = a − n × ⌊a/n⌋, so inputs like 7.5 mod 2.5 = 0 are valid. However, for most programming and mathematical contexts, modulo is used exclusively with integers.
A result of 0 means the dividend is exactly divisible by the divisor — there is no remainder. For example, 12 mod 4 = 0 because 12 ÷ 4 = 3 exactly. This is how you test for divisibility or check whether a number is even (n mod 2 = 0).
The percent sign % is the modulo operator in most languages: Python, C, Java, JavaScript, and C++ all use %. However, Python uses floored division (always non-negative result), while C, Java, and JavaScript use truncated division (result can be negative for negative inputs). In Excel and Google Sheets, use the MOD() function.
Modular arithmetic is a system of arithmetic where numbers 'wrap around' after reaching a certain value called the modulus. It is essentially extended repeated use of the modulo operation. The integers 0, 1, 2, …, n−1 form a complete residue system modulo n. It is foundational in number theory and cryptography.
Only sources that have been reviewed are shown. Unverified citations are never published.
Spotted an inaccuracy or have an idea to improve this calculator? Let us know.
We use cookies to operate the site, and — with your consent — to show advertising and measure usage. You can change your choice anytime in Cookie Settings.