Modulus Calculator

Calculate the modulus (remainder) of a division operation

Enter a dividend and divisor to find the remainder after division, the floor quotient, and whether the dividend is divisible by the divisor.

Modulus and remainder: what they mean and how they differ

The modulus operation finds the remainder left over after dividing one integer by another. For example, 17 divided by 5 gives a quotient of 3 with a remainder of 2 (since 5 x 3 = 15 and 17 - 15 = 2). This remainder is what the modulus operation returns. The notation used is 17 mod 5 = 2, and in most programming languages the percent symbol is used: 17 % 5 = 2.

Modulus is used in a wide range of practical applications. Checking whether a number is even or odd is a modulus test: if n % 2 = 0, the number is even; if n % 2 = 1, it is odd. Checking divisibility is also a modulus test: 100 is divisible by 4 because 100 % 4 = 0. In time calculations, converting a total number of minutes to hours and minutes uses modulus: total_minutes % 60 gives the leftover minutes. Cyclic patterns in schedules, calendars, and circular buffers in software all rely on modulus arithmetic.

This calculator distinguishes between two related but subtly different concepts: the JavaScript modulo operator (%) and the mathematical modulus. For positive numbers they give the same result. For negative dividends, the behaviour differs. The JavaScript % operator returns a result with the same sign as the dividend: -7 % 3 = -1 in JavaScript. The mathematical modulus (sometimes called the Euclidean modulus) always returns a non-negative result: -7 mod 3 = 2, because -7 = 3 x (-3) + 2 and 2 is between 0 and 2 (exclusive).

The floor quotient (Math.floor(dividend / divisor)) is used in the mathematical modulus calculation. For -7 / 3, the floor of -2.333 is -3. Then -7 - (3 x -3) = -7 + 9 = 2. For positive dividends and divisors, the floor quotient is the same as the ordinary quotient and both modulus definitions agree.

Why the distinction between modulo and modulus matters

In mathematics, the modulus is always non-negative by definition. Number theory uses the modulus extensively in congruence relations: a is congruent to b modulo n (written a = b mod n) if their difference is divisible by n. This relation is symmetric and works consistently only when the modulus is always taken as non-negative. In cryptography, modular exponentiation and modular inverse both rely on the non-negative modulus convention.

In programming, the % operator behaviour with negative numbers varies by language. Python always returns a non-negative result for positive divisors, matching the mathematical convention. C, C++, JavaScript, and Java return a result with the same sign as the dividend. This is a well-known source of bugs when programmers assume % always gives a non-negative result. This calculator shows both so you can choose the value appropriate for your context.

Practical examples of modulus

A month calculation: January is month 1, and adding 5 months gives June (month 6). But adding 5 months to October (month 10) gives 15, and 15 mod 12 = 3, which is March of the following year. A clock calculation: if it is currently 11 hours into the day and you add 5 hours, 11 + 5 = 16, and 16 mod 12 = 4 (4 pm). An ISBN check digit, a credit card Luhn check, and many hash functions all use modulus arithmetic as a core step. This calculator handles all these scenarios for integer and decimal inputs.

Last updated: 2026-05-06