Modulo Calculator
This modulo calculator is a handy tool if you need to find the result of modulo operations. All you have to do is input the initial number x and integer y to find the modulo number r, according to x mod y = r
. Read on to discover what modulo operations and modulo congruence are, how to calculate modulo and how to use this calculator correctly.
What are modulo operations?
Imagine a clock hanging on a wall. Let's say it is late at night — 11 pm 🕚. You wonder what time it will be when you wake up after 8 hours of sleep. You can't just add 8 to 11, as there is no such time as 19 am. To find the correct answer, perform a modulo operation (mod 12) — add these two numbers and keep subtracting 12 until you get a number lower than 12. In this case, 7. You just calculated you will wake up at 7 am 🕖.
Modulo operations, in the case of the clock, are so intuitive that we don't even notice them. In mathematics, there are many types of more elaborate modulo operations that require more thought. We say that
x mod y = r
if there exists an integer q
(called quotient) that satisfies the equation
x = qy + r
The number r
is the remainder of the division, x
is the dividend, and `y' is the divisor (our remainder calculator explains how to obtain the remainder of a division).
If the modulo definition doesn't appeal to you, and you're still unsure how to calculate modulo, have a look at the next paragraph, and everything should become crystal clear.
What is modulo congruence?
Two numbers, a
and b
, are said to be congruent modulo n if their difference a - b
is divisible by n
, i.e., a - b
is a multiple of n
. For example, 24 and 34 are congruent modulo 10 because their difference 24 - 34 = -10
is a multiple of 10.
Mathematically, the modulo congruence formula is written as:
a ≡ b (mod n)
and n
is called the modulus of the congruence.
Alternately, a
and b
are congruent modulo n if they have the same remainder when divided by n:
a mod n = r
b mod n = r
where r
is a common remainder. For example, 24 modulo 10 and 34 modulo 10 are both 4, and so they are congruent modulo 10.
Let's have a look at another example:
9 ≡ 21 (mod 6)
because 21 - 9 = 12
is a multiple of 6. The same statement can also be written as 6 | (21 - 9)
, which reads as 6 divides 21-9. Or, equivalently, 21 and 9 have the same remainder when we divide them by 6:
9 mod 6 = 3
21 mod 6 = 3
How to calculate the modulo — an example
It's not a difficult task to calculate the modulo by hand. Just follow the steps below!
-
Start by choosing the initial number (before performing the modulo operation). Let's say it is 250. This is our dividend.
-
Choose the divisor. Let's pick 24. The operation we want to perform is
250 mod 24
(or250 % 24
using a different convention). -
Divide one number by the other and round the answer down to the nearest integer. The quotient
250 / 24
equals 10.42, and we round it down to 10. This is the quotient. This operation is also called floor division — a type of division in which we throw away the fractional part of the answer. You can read more about it in our floor division calculator. -
Multiply the divisor by the quotient. So it's
10 × 24 = 240
in our example. -
Subtract this number from your initial number (dividend). Here:
250 - 240 = 10
. -
The number you obtain is the result of the modulo operation. We can write it down as
250 mod 24 = 10
.
How to use our mod calculator? 10 mod 3 and other modulo examples
Determining a modulo with our tool is easy and convenient. To find the result of modulo operations between integer numbers, you need to:
- Type the initial number — dividend — into the first box. Let's take the example from the previous paragraphs, so enter 250.
- Enter the divisor. It's 24 in our case.
- Tadaaa! Our modulo calculator will return to you your result — the remainder! And that's not a surprise; it's equal to 10 — the same number as we calculated before.
Below, you'll find some typical queries concerning the modulo:
- 1 mod 1 = 0 (as mod 1 is always 0)
- 1 mod 2 = 1
- 1 mod 3 = 1
- 5 mod 2 = 1
- 5 mod 3 = 2
- 6 mod 3 = 0
- 7 mod 3 = 1
- 10 mod 3 = 1
- 18 mod 3 = 0
- 100 mod 3 = 1
- 100 mod 7 = 2
If you don't see the one you want to find here, don't hesitate to use our modulo calculator!
Modular arithmetic
Modular arithmetic is a way of performing four arithmetic operations +, -, ×, /
in which numbers "wrap around" a fixed modulus. Let's sum up what we've learned about different representations of modulo operations — all those statements below are equivalent:
A ≡ B (mod C)
;A mod C = B mod C
;C | (A - B)
; andA = B + K × C
whereK
is some integer.
We can also perform calculations on modulo operations.
1. Modular addition and subtraction
(A + B) mod C = (A mod C + B mod C) mod C
(A - B) mod C = (A mod C - B mod C) mod C
So, the modulo of the sum of two numbers is equal to the sum of the modulo of those numbers calculated separately, then take the modulo of this result. The first stage is made to get rid of the quotient part, and then the mod operation is used again. Have a look at the example:
-
A = 11, B = 7, C = 4
(11 + 7) mod 4 = (11 mod 4 + 7 mod 4) mod 4
left part of the equation:
(11 + 7) mod 4 = 18 mod 4 = 2
right part of the equation:
(11 mod 4 + 7 mod 4) mod 4 = (3 + 3) mod 4 = 6 mod 4 = 2
Analogically, the calculations are the same for subtraction.
2. Modular multiplication
(A × B) mod C = (A mod C × B mod C) mod C
Such an equation may be useful when dealing with big numbers, and we don't know the modulo of that large number instantly. Let's have a look at the same example (A = 11, B = 7, C = 4) — can you find the result of 77 mod 4
on the spot? 11 mod 4
and 7 mod 4
are easier to calculate:
-
(11 × 7) mod 4 = (11 mod 4 × 7 mod 4) mod 4
Left part of the equation:
(11 × 7) mod 4 = 77 mod 4 = 1
Right part of the equation:
(11 mod 4 × 7 mod 4) mod 4 = (3 × 3) mod 4 = 9 mod 4 = 1
3. Modular exponentiation
A^B mod C = ((A mod C)^B) mod C
This formula is even more useful when dealing with large numbers. Consider the same example:
-
(11 ^ 7) mod 4 = ((11 mod 4)^7) mod 4
Left part of the equation:
(11 ^ 7) mod 4 = 19487171 mod 4 = 3
Right part of the equation:
((11 mod 4)^7) mod 4 = (3^7) mod 4 = 2187 mod 4 = 3
The usefulness of this formula may not be so obvious in this example, as we still need to use the calculator to find the exponentiation result (assuming that you don't know the result of 37 immediately). So, have a look at another problem: we want to calculate the A^B mod C
for large values of B — like, e.g., 100. Unfortunately, our calculator can't handle numbers as big as this due to overflow — only numbers up to 2^60 can be held. You can, however, use the multiplication properties to get around this problem:
2^100 = 2^50 × 2^50
2^100 mod 3 = (2^50 mod 3 × 2^50 mod 3) mod 3
2^100 mod 3 = (1 × 1) mod 3 = 1
Even faster modular exponentiation methods exist for some specific cases (if B is a power of 2). If you want to read about them and practice modular arithmetic, check out our dedicated power mod calculator.
Modulo definition ambiguity
The word modulo comes from the Latin word modus, meaning a measure. Usually, when we use the word modulo, we mean the modulo operation, like, e.g., 11 mod 3 equals 2 — so it's simply finding the remainder. In a strict definition, the modulo means:
With respect to specified modulus.
or
A is the same as B modulo C, except for differences accounted for or explained by C.
Which is the definition we wrote about in the congruence modulo paragraph.
However, modulo is not only used in a mathematical context. Sometimes you may hear it in everyday conversation, where it means ignoring, not accounting for something, with due allowance for something, etc. For example:
The design was best so far, modulo that parts that still need some modification.
Percent — a symbol of a modulo operation
The modulo operation is often used in programming languages. For this, % — percent — is used to denote this operation (or sometimes the remainder operator for negative numbers). If you're curious about the origins of the % sign, we strongly encourage you to read the short paragraph we put together about the history of the percent sign.
You do need to be careful, as there's some ambiguity with the modulo definition when negative values are taken into account. There are two possible choices for the remainder — one negative and the other positive — and the result depends on the implementation in the chosen programming language.
Modulo applications
They might not be obvious at first glance, but there are many applications of modulo — from everyday life to math and science problems!
-
The most obvious and well-known example is the so-called clock arithmetic 🕞. It may be adding the hours, like in the explanation of modulo above, or minutes or seconds as well!
Nobody will say, "You have 40 minutes and 90 seconds left", right? The only option is to perform a modulo operation and find the quotient and remainder —
60 × 1 + 30 = 90
. 41 minutes and 30 seconds sounds much better. -
Modulo operations are used to calculate the checksums of serial numbers. Check digits are used mostly in long numbers, and they are the digits computed by an algorithm. They are there to inform you about errors arising, e.g., from mistyping. You can find the application of modulo in the following:
- In our check digit calculator:
- GTIN, UPC, and EAN check digits are used to confirm the integrity of a barcode. The formula for the check digits uses modulo 10.
- ISBN and ISSN numbers, which are unique periodic and book identifiers, have modulo 11 or modulo 10.
- IBAN — International Bank Accounts Numbers - make use of modulo 97 to check whether a client didn't mistype the number.
- NPI — US National Provider Identifier uses the modulo 10 operation to calculate the tenth digit.
As the check digits are used to capture human transcription errors, they are often used for long serial numbers. Other examples of check digits algorithms using modulo operations:
- National identification number (e.g., in Iceland, Turkey, Poland)
- Fiscal identification number (Spain)
- Vehicle identification number (US)
- ...and many, many more.
- In our check digit calculator:
-
It is applied in many scientific areas, like computer algebra, cryptography, computer science, or simple school math — like in a Euclidean algorithm for the greatest common factor calculation.
-
Modulo is useful whenever you need to split something. A real-life example may be sharing a pizza with your friends or family.
-
There are even uses for modulo in Minecraft.
mod 64
will tell you how many full stacks of cobblestone you'll need to build that Creeper statue.
Assuming that there are 10 slices in a big party pizza, and you are a group of three. How many slices are left when you share the pizza equally?
That's exactly the case when you can use modulo! 10 mod 3 = 1
. In other words, 10 divided by 3 equals 3, but it remains 1 slice left 🍕. That was not the most difficult example, but we hope you can see the usefulness of modulo.
Oh, no! We're getting hungry. Let's leave this yummy distraction and go back to Earth. If you're interested in finding more funny applications of modular arithmetic, check out this
blog post.What is a modulo operator?
The modulo operator is used to find the remainder during a division of two numbers. The operator is represented by the symbol %
in most programming languages. It is also known as the remainder operator. As an example, 5
mod 2
returns 1
.
How to calculate modulo division?
To calculate modulo division: subtract the divisor from the dividend until the resultant is less than the divisor.
What are the components of modulo division?
The components of modulo division are dividend, divisor, quotient, and remainder. The remainder is the answer or end result of the operation.
How much is 17 mod 3?
17 mod 3 equals 2 since dividing 17 by 3 gives a quotient of 5 and a remainder of 2. The remainder is the result of the modulus operation. In simpler terms, 17 mod 3 = 2
.