Modulo operation
Find the floating point remainder (modulo) of the division.
What does modulo operation do?
The modulo operation it's a way to determine the remainder of a division operation. Modulo operation returns the whole number remainder instead of just returning the result of the division.
How do you calculate mod?
- Choose the initial number (dividend)
- Choose the divisor
- Divide one number by the other and drop the number after the dot (fractional part)
- Multiply the divisor by the result after previous division
- Subtract this number from initial number and result of it's result of the modulo operation
Here is example:
- Initial number - 25
- Divisor - 7
- 25 / 7 = 3.5714
- 7 * 3 = 21
- 25 - 21 = 4
So, result of 25 mod 7 operation is equal to 4.
Modulo operation table
Let's take 10 as dividend.
-
10 mod 1 = 0
-
10 mod 2 = 0
-
10 mod 3 = 1
-
10 mod 4 = 2
-
10 mod 5 = 0
-
10 mod 6 = 4
-
10 mod 7 = 3
-
10 mod 8 = 2
-
10 mod 9 = 1
-
10 mod 10 = 0