Modulo Calculator
Calculate a mod b to find the remainder after division. Check if numbers are multiples or divisible.
Calculate a mod b to find the remainder after division. Essential for programming (% operator) and checking divisibility.
How to Use
How to Calculate Modulo
The modulo operation finds the remainder when dividing a by b. To calculate by hand, simply divide the two numbers and note the remainder. For example, to find 27 mod 6: divide 27 by 6 to get 4 with a remainder of 3, so 27 mod 6 = 3.
Understanding Modulo:
- a mod b = remainder after dividing a by b
- In programming:
a % bis the same as a mod b - Result is always less than the divisor (for positive numbers)
- If remainder is 0, then a is exactly divisible by b
When Divisor is Greater Than Dividend:
When b > a (for positive numbers), the remainder equals the dividend itself. For example, 1 mod 2 = 1 because 2 goes into 1 zero times with remainder 1. Similarly, 5 mod 10 = 5.
What is Modulo Calculator?
Modulo (abbreviated as mod) is a mathematical operation that finds the remainder after division of one number by another. If you divide a by b and get a remainder of n, you would write: a mod b = n.
The modulo operation is fundamental in computer science and programming. In most programming languages, the % operator performs the modulo operation. For example, 17 % 5 returns 2.
Common uses: checking if a number is even or odd (n mod 2), creating circular arrays, limiting values to a range, cryptography algorithms, hash functions, and determining if one number is a multiple of another.
Formula
Modulo Formula:
a mod b = a - (b × floor(a / b))
Or simply: divide a by b and take the remainder
Verification:
a = (quotient × b) + remainder
Example: 27 = (4 × 6) + 3 ✓
Multiple Check:
If a mod b = 0, then a is a multiple of b
Example: 496 mod 4 = 0 → 496 is a multiple of 4
Example: 226 mod 4 = 2 → 226 is NOT a multiple of 4
Examples
Example 1: 27 mod 6
Divide: 27 ÷ 6 = 4 remainder 3
Verify: 4 × 6 + 3 = 24 + 3 = 27 ✓
27 mod 6 = 3
Example 2: Check if 496 is a multiple of 4
Calculate: 496 mod 4
Divide: 496 ÷ 4 = 124 remainder 0
496 mod 4 = 0 → Yes, 496 is a multiple of 4
Example 3: 1 mod 2 (divisor > dividend)
2 goes into 1 zero times
Remainder equals the dividend: 1
1 mod 2 = 1
Example 4: Even/Odd Check
To check if n is even: n mod 2 = 0
To check if n is odd: n mod 2 = 1
17 mod 2 = 1 → 17 is odd
24 mod 2 = 0 → 24 is even