computational operation
In computing and mathematics, the modulo operation returns the remainder or signed remainder of a division, after one number is divided by another, the latter being called the modulus of the operation. … Wikipedia
🌐
Wikipedia
en.wikipedia.org › wiki › Modulo
Modulo - Wikipedia
1 day ago - Some calculators have a mod() function button, and many programming languages have a similar function, expressed as mod(a, n), for example. Some also support expressions that use "%", "mod", or "Mod" as a modulo or remainder operator, such as a % n or a mod n.
Discussions

elementary number theory - Notation for modulo - Mathematics Stack Exchange
Is there a established notation for the remainder of integer division? For example, I want a function gives zero for non-negative even integers and one for non-negative odd integers. In computer c... More on math.stackexchange.com
🌐 math.stackexchange.com
October 11, 2017
Understanding The Modulus Operator % - Stack Overflow
I understand the Modulus operator in terms of the following expression: 7 % 5 This would return 2 due to the fact that 5 goes into 7 once and then gives the 2 that is left over, however my confusion More on stackoverflow.com
🌐 stackoverflow.com
Why isn't there a symbol for the modulo operator?

I suspect it is because "modulo" describes an equivalence class, rather than a particular number: 4 (mod 7) is technically the set of all integers n such that 7|(n-4); this set is precisely the same set as -3 (mod 7), so what should "25%7" equate to? 4? -3? 25? I don't believe it is common enough as an operation in mathematics to warrant identifying a canonical result: e.g. as the unique representative between 0 and n-1; it is more commonly used to set up the structure being worked on/in (e.g. Z_p, integers modulo p).

More on reddit.com
🌐 r/math
15
12
July 20, 2013
Modulo operator
A modulo is a mathematical operator used in modular arithmetic You can think about modular arithmetic like how time on an analog clock works. In a 12 hr clock, if it’s currently 10, in 3 hours it will be 1, not 13. This is expressed as 10 + 3 mod 12. The modulo operator returns that result. num = (10 + 3) % 12 print(num) Would output 1. People like thinking about this as the remainder, but that’s not really accurate. For example: -1 % 4 would actually equal 3. If you think about a 4-hr clock and go back 1 hour, you end up at 3. More on reddit.com
🌐 r/learnpython
48
24
November 23, 2023
🌐
Codecademy
codecademy.com › forum_questions › 519c46d16d9235a79e000b76
Modulo Symbol On The Keyboard | Codecademy
I wasted time looking for the modulo symbol on the keyboard, googling it…etc. Apparently, it is the percent symbol, which is on top of the numeral 5 on the keyboard (SHIFT +5). Modulo is %. I wish the instructor had made a note of this.
🌐
MathWorks
mathworks.com › matlab › mathematics › elementary math › arithmetic operations
mod - Remainder after division (modulo operation) - MATLAB
b = mod(a,m) returns the remainder after division of a by m, where a is the dividend and m is the divisor. This function is often called the modulo operation, which can be expressed as b = a - m.*floor(a./m).
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Operators › Remainder
Remainder (%) - JavaScript | MDN
In JavaScript, the modulo operation (which doesn't have a dedicated operator) is used to normalize the second operand of bitwise shift operators (<<, >>, etc.), making the offset always a positive value.
🌐
Wikipedia
en.wikipedia.org › wiki › Modular_arithmetic
Modular arithmetic - Wikipedia
1 week ago - This notation is not to be confused with the notation b mod m (without parentheses), which refers to the remainder of b when divided by m, known as the modulo operation: that is, b mod m denotes the unique integer r such that 0 ≤ r < m and r ≡ b (mod m).
Find elsewhere
🌐
GeeksforGeeks
geeksforgeeks.org › c++ › modulo-operator-in-c-cpp-with-examples
Modulo Operator (%) in C/C++ with Examples - GeeksforGeeks
July 12, 2025 - In C or C++, the modulo operator (also known as the modulus operator), denoted by %, is an arithmetic operator.
Top answer
1 of 9
226

(This explanation is only for positive numbers since it depends on the language otherwise)

Definition

The modulo operation returns the remainder or signed remainder of a division, after one number is divided by another, the latter being called the modulus of the operation. (source: wikipedia)

For instance, 9 divided by 4 equals 2 but it remains 1. Here, 9 / 4 = 2 and 9 % 4 = 1.

Image source: Wikimedia

In your example: 5 divided by 7 gives 0 but it remains 5 (5 % 7 == 5).

Calculation

The modulo operation can be calculated using this equation:

a % b = a - floor(a / b) * b
  • floor(a / b) represents the number of times you can divide a by b
  • floor(a / b) * b is the amount that was successfully shared entirely
  • The total (a) minus what was shared equals the remainder of the division

Applied to the last example, this gives:

5 % 7 = 5 - floor(5 / 7) * 7 = 5

Modular Arithmetic

That said, your intuition was that it could be -2 and not 5. Actually, in modular arithmetic, -2 = 5 (mod 7) because it exists k in Z such that 7k - 2 = 5.

You may not have learned modular arithmetic, but you have probably used angles and know that -90° is the same as 270° because it is modulo 360. It's similar, it wraps! So take a circle, and say that its perimeter is 7. Then you read where is 5. And if you try with 10, it should be at 3 because 10 % 7 is 3.

2 of 9
37

Two Steps Solution.

Some of the answers here are complicated for me to understand. I will try to add one more answer in an attempt to simplify the way how to look at this.


Short Answer:

Example 1:

7 % 5 = 2

Each person should get one pizza slice.

Divide 7 slices on 5 people and every one of the 5 people will get one pizza slice and we will end up with 2 slices (remaining). 7 % 5 equals 2 is because 7 is larger than 5.


Example 2:

5 % 7 = 5

Each person should get one pizza slice

It gives 5 because 5 is less than 7. So by definition, you cannot divide whole 5items on 7 people. So the division doesn't take place at all and you end up with the same amount you started with which is 5.


Programmatic Answer:

The process is basically to ask two questions:

Example A: (7 % 5)

(Q.1) What number to multiply 5 in order to get 7?

Two Conditions: Multiplier starts from `0`. Output result should not exceed `7`. 

Let's try:

Multiplier is zero 0 so, 0 x 5 = 0

Still, we are short so we add one (+1) to multiplier.

1 so, 1 x 5 = 5

We did not get 7 yet, so we add one (+1).

2 so, 2 x 5 = 10

Now we exceeded 7. So 2 is not the correct multiplier. Let's go back one step (where we used 1) and hold in mind the result which is5. Number 5 is the key here.

(Q.2) How much do we need to add to the 5 (the number we just got from step 1) to get 7?

We deduct the two numbers: 7-5 = 2.

So the answer for: 7 % 5 is 2;


Example B: (5 % 7)

1- What number we use to multiply 7 in order to get 5?

Two Conditions: Multiplier starts from `0`. Output result and should not exceed `5`. 

Let's try:

0 so, 0 x 7 = 0

We did not get 5 yet, let's try a higher number.

1 so, 1 x 7 = 7

Oh no, we exceeded 5, let's get back to the previous step where we used 0 and got the result 0.

2- How much we need to add to 0 (the number we just got from step 1) in order to reach the value of the number on the left 5?

It's clear that the number is 5. 5-0 = 5

   5 % 7 = 5

Hope that helps.

🌐
UCI Music
music.arts.uci.edu › dobrian › maxcookbook › modulo-operator
Modulo operator: % | Max Cookbook
The % object is the arithmetic operator “modulo” (a.k.a. “mod”), used in modular arithmetic. Whereas the / object (“divided by”) divides the left input by the right input and outputs the quotient, the % object divides the left input by the right output and outputs the remainder.
🌐
freeCodeCamp
freecodecamp.org › news › the-python-modulo-operator-what-does-the-symbol-mean-in-python-solved
The Python Modulo Operator - What Does the % Symbol Mean in Python? (Solved)
December 29, 2019 - The % symbol in Python is called the Modulo Operator. It returns the remainder of dividing the left hand operand by right hand operand.
🌐
Math is Fun
mathsisfun.com › numbers › modulo.html
Modulo Operation
The modulo (or "modulus" or "mod") is the remainder after dividing one number by another. ... So 14 o'clock becomes 2 o'clock. We are only interested in where we end up, not how many times around. ... Some programming languages use the percent sign: 14 % 12 = 2, but % is just a convenient symbol ...
🌐
GeeksforGeeks
geeksforgeeks.org › python › what-is-a-modulo-operator-in-python
Modulo operator (%) in Python - GeeksforGeeks
December 20, 2025 - The modulo operator (%) in Python is used to find the remainder after dividing one number by another. It works with both integers and floating-point numbers and is commonly used in tasks like checking even or odd numbers, repeating patterns, ...
🌐
Matthew J. Clemente
blog.mattclemente.com › 2019 › 07 › 12 › modulus-operator-modulo-operation
What is the Modulus Operator? A Short Guide with Practical Use Cases | Matthew J. Clemente
July 12, 2019 - When you're using the modulus operator for even/odd alternation, you're actually taking advantage of one of its more helpful properties, though you might not realize it. Here's the property: the range of x % n is between 0 and n - 1, which is to say that the modulo operation will not return more than the divisor.[3]
🌐
Processing
processing.org › reference › modulo.html
% (modulo) / Reference / Processing.org
That is, a number cannot be divided by any number larger than itself. For example, when 9 is divided by 10, the result is zero with a remainder of 9. Thus, 9 % 10 produces 9. Modulo is extremely useful for ensuring values stay within a boundary, such as when keeping a shape on the screen.
🌐
Josh W. Comeau
joshwcomeau.com › javascript › modulo-operator
Understanding the JavaScript Modulo Operator • Josh W. Comeau
One of the most commonly-misunderstood operators is Modulo (%). In this tutorial, we'll unpack exactly what this little bugger does, and learn how it can help us solve practical problems.