Skip to main content

Mod Calculator

Blake Boege
Written by Blake Boege · Founder, Calculator Answers

A mod calculator computes the modulo operation, which returns the remainder after dividing one integer by another. Using the mathematical Euclidean division definition, the remainder is always non-negative and strictly smaller than the absolute value of the divisor. Modulo arithmetic is essential in programming, calendar math, index wrapping, and cryptography.

Compute the modulo (mod) operation of two integers. Get the remainder and division quotient instantly.

Quick Answer

Calculate the modulo (mod) of two integers. Input the dividend and divisor to get the remainder and quotient instantly.

Whole number to divide. · e.g. 17

Cannot be 0. · e.g. 5

Returns the quotient and a non-negative remainder. Dividend = divisor × quotient + remainder.

Remainder

Quotient and remainder

3 R 2

17 ÷ 5

Dividend17
Divisor5
Quotient3
Remainder2
Statement17 = 5 × 3 + 2
Modulo17 mod 5 = 2

The calculator returns a non-negative remainder (Euclidean division), so 0 ≤ remainder < |divisor|. The JavaScript % operator gives a different sign for negative dividends.

Was this helpful?

Examples

17 mod 5

Quotient = 3, Remainder (Mod) = 2

100 mod 7

Quotient = 14, Remainder (Mod) = 2

-7 mod 3 (Euclidean)

Quotient = -3, Remainder (Mod) = 2

How it works

Formula · a mod n is the remainder after dividing a by n

Modulo Arithmetic Rules

The modulo operation computes the remainder from Euclidean integer division. For any integers a and b (where b ≠ 0):

a mod b = r

where a = b × q + r, and the remainder r satisfies the constraint 0 ≤ r < |b|.

To compute standard fractional or long divisions, you can visit our general remainder calculator or use our GCF calculator to find common denominators using Euclidean algorithms.

Related division and factor tools

Frequently asked questions

In mathematics and computing, the modulo operation returns the remainder or signed remainder of a division, after one number is divided by another. It is written as 'a mod n'. For example, 17 mod 5 is 2.

Modulo division divides a dividend 'a' by a divisor 'n', finds the integer quotient, and returns the leftover remainder. Formally, a = n × q + r, where 0 ≤ r < |n|. The value 'r' is the modulo result.

Yes, for positive numbers. For negative numbers, standard computer programming languages handle the sign differently. In pure math, the modulo operation always yields a non-negative remainder, which is the convention this calculator uses.

Modulo is the workhorse of index arithmetic in programming. Wrapping an index around a circular array is i mod length. Distributing keys across buckets in a hash table is hash mod bucketCount. Testing parity is n mod 2. Rolling a clock over is hours mod 12, and calendar and cryptographic code lean on it constantly. If you are dividing on paper instead, the remainder calculator frames the same operation as long division.