math calculators

Modulo Calculator

Quickly find the remainder when one integer is divided by another. Essential for programming, cryptography, and checking divisibility in everyday math problems.

About this calculator

The modulo operation returns the remainder left over after dividing one number (the dividend) by another (the divisor). The formula is expressed as a % b, where 'a' is the dividend and 'b' is the divisor. Mathematically, a % b = a − b × floor(a / b). For example, 17 % 5 equals 2, because 5 goes into 17 three times (5 × 3 = 15), leaving a remainder of 2. Modulo is fundamental in computer science for tasks like determining whether a number is even or odd (n % 2), cycling through array indices, and implementing hash functions. It also appears in clock arithmetic, calendar calculations, and modular exponentiation used in encryption algorithms like RSA.

How to use

Suppose you want to find 29 % 6. Enter 29 as the Dividend (a) and 6 as the Divisor (b). The calculator computes: 6 goes into 29 four times (6 × 4 = 24). Subtract: 29 − 24 = 5. So 29 % 6 = 5. This tells you that 29 divided by 6 leaves a remainder of 5. Try another: 100 % 7 → 7 × 14 = 98, so 100 − 98 = 2. The result is 2.

Frequently asked questions

What is the difference between modulo and remainder in mathematics?

In most everyday contexts, modulo and remainder mean the same thing — the leftover value after division. However, they differ when negative numbers are involved. The remainder can be negative (matching the sign of the dividend), while the modulo result typically follows the sign of the divisor. For example, −7 % 3 gives −1 as a remainder in some languages, but 2 as a modulo result in others. Most programming languages implement their own convention, so it's worth checking how your language handles negative operands.

How is the modulo operation used in programming and computer science?

Modulo is one of the most frequently used operations in programming. It's used to check whether a number is even or odd (n % 2 == 0 means even), to wrap array indices so they cycle back to zero, and to create hash functions that map large numbers into a fixed range. It's also central to scheduling algorithms, generating pseudo-random numbers, and implementing circular buffers. In cryptography, modular arithmetic underpins RSA encryption and elliptic curve algorithms.

Why does the modulo operation return zero for certain inputs?

The modulo operation returns zero when the dividend is perfectly divisible by the divisor — meaning there is no remainder. For instance, 12 % 4 = 0 because 4 divides evenly into 12 exactly three times. This is useful for detecting multiples: if a % b == 0, then a is a multiple of b. Programmers commonly use this to trigger an action every nth iteration in a loop, or to test divisibility without performing long division by hand.