## Modulo calculator

Calculate the Modulo of x/n :

#### Modulo Calculator

Result:

 x mod y:

### What is Modulo?

The modulo operator displays the modulo of two numbers. In mathematics, the modulo operator is also known as the mod function or modulo function. Modular arithmetic was introduced in the 19th century by the renowned mathematician, Carl Friedrich Gauss.

Mathematically, the mod function is written as a mod b = c, where a, b and c are integers. In computer science, the mod function is written as a % b = c. Mathematically speaking, the modulo operator returns the remainder c when a is divided by b. It is exclusively used to find the remainder after the division of two numbers.

If a is greater than b, then it is quite easy to find the remainder after a is divided by b. For example, 14 mod 3 = 2. This means that, when 14 is divided by 3, the remainder is 2. However, if a is less than b, then the remainder is a itself. For example, 2 mod 5 = 2. In this case, a (2) is less than b (5), so we get the remainder as a (2) itself.

If a is a multiple of b, then the modulo operator returns 0. For example, 6 mod 2 = 0.

Another widely used representation of the modulo function is a ≡ c (mod b). This means that is c is the remainder when a is divided by b. For example, 14 ≡ 2 (mod 3), or 12 ≡ 0 (mod 3).

### Properties of Modulo

Given below are some important properties of modulo.

Dividend – The number which is being divided. In the modulo operation a mod b = c, a is the dividend. It is getting divided by b.

Divisor – The number which divides another number either completely or with a remainder. In the modulo operation a mod b = c, b is the divisor. It divides a.

Remainder – The number obtained when the divisor does not completely divide the dividend. If the divisor divides the dividend completely, the remainder is 0. In the modulo operation a mod b = c, c is the remainder.

Modulo operator – Denoted by “mod” in mathematics and “%” in computer science, the modulo operator returns the remainder after the division of two integers. If the divisor divides the dividend completely, then the modulo operator returns 0.

Closure property – When an integer is divided by another, the remainder is always an integer. The integer may be positive or negative. For example, 4 mod 5 = 4 and -4 mod 5 = 1.

Non-commutative property – The modulo function is not commutative. When we swap the places of a and b, c changes. For example, 4 mod 5 = 4 and 5 mod 4 = 1.

### The modulo function in use

The numbers involved in the process of division may not always be positive. We consider the following cases when one or both the number may be negative.

In a mod b = c, if a < 0, then c = a + b. For example, -2 mod 5 = c. Here, c = -2 + 5 = 3. Hence, -2 mod 5 = 3. In this case, c is a positive number.

In a mod b = c, if b < 0, then c = a + b. For example, 2 mod -5 = c. Here, c = 2 - 5 = -3. Hence, 2 mod -5 = -3. In this case, c is a negative number.

In a mod b = c, if both a < 0 and b < 0, and the absolute value of a is less than b, then c = a, but with a negative sign. Consider the following examples:

-4 mod -16 = -4. Here, c = -4.

-4 mod -15 = -4. Here, c = -4.

In a mod b = c, if both a < 0 and b < 0, and the absolute value of b is less than a, then c = a mod b. We do the usual division process to obtain c, but it has a negative sign. If, however, the absolute value of a completely divides the absolute value of b, then the remainder is 0. Consider the following examples:

-15 mod -7 = -1. Here, c = -1.

-14 mod -7 = 0. Here, c = 0.

-23 mod -5 = -3. Here, c = -3.

-20 mod -5 = 0. Here, c = 0.

In a mod b = c, if both a > 0 and b > 0, then c is obtained using the usual division process. For example,

23 mod 5 = 3.

5 mod 13 = 5.

### Areas of application

Modulo has numerous applications in daily life. Some examples are as follows.

• In modular arithmetic, numbers wrap around when they reach a certain size known as the modulus. This is known as the arithmetic of remainders. For example, 1 mod 4 = 1, 2 mod 4 = 2, 3 mod 4 = 3, 4 mod 4 = 0, 5 mod 4 = 1, 6 mod 4 = 2 and so on.
• We use modular arithmetic for counting hours. We count up to 12, and then start again at 1. Thus, five hours after eight o’ clock is one o’clock. The same situation applies for the days of the week.
• Modular arithmetic is used extensively in pure mathematics, particularly number theory. This, in turn, can be used to calculate international standard book numbers (ISBNs) and bank identifiers and to find any discrepancies in them.
• Modular arithmetic forms the foundation of public key cryptography systems which are used in commerce.