Módulo/Resto (a mod n)

a mod n.
Created by
Renato Passos, Eng. de Software
Reviewed by
Renato Passos, Eng. de Software

Last updated: Apr 18, 2026

resto
2,00

Formula

a mod n

About this calculator

The modulus calculator (a mod n) is a simple tool to compute the remainder of the division of an integer a by an integer n. The result is always between 0 and n-1, representing what remains after division. For example, 7 mod 3 yields 1 because 7 divided by 3 equals 2 with remainder 1.

It works by finding the remainder r such that a = q * n + r, where q is the integer quotient and r is in the range [0, n-1]. For negative numbers, the remainder is adjusted to be non-negative, following the mathematical definition. This calculator ensures a non-negative result.

Use this calculator when dealing with cycles (e.g., 23 hours mod 12 = 11), programming array indices, cryptography (RSA), or divisibility checks. It is also handy for checking even numbers (a mod 2 = 0) or distributing items evenly among groups.

Caution: some computer systems handle negative modulus differently, possibly returning a negative remainder. This calculator follows the standard mathematical definition (non-negative remainder). Verify your problem's context, especially with negative numbers.

Frequently asked questions

What does a mod n mean?

a mod n is the remainder when a is divided by n. For example, 10 mod 3 = 1 because 10 divided by 3 equals 3 with remainder 1.

How to calculate modulus for negative numbers?

This calculator returns a non-negative remainder for negative numbers. For instance, -7 mod 3 yields 2 because -7 = -3*3 + 2.

What's the difference between mod and remainder?

In mathematics, mod and remainder are the same when the divisor is positive. For negatives, some programming languages give a negative remainder, but here we use the mathematical non-negative remainder.

What is modulus used for in everyday life?

Modulus is used to calculate time (e.g., 23h in 12h format is 23 mod 12 = 11), check parity, distribute tasks into groups, and in encryption algorithms.

Can I use this calculator for decimal numbers?

No, it works only with integers. For decimals, use a remainder calculator for decimals.

Other Sequencias e Numeros calculators