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.

?
Max 15 characters per number
Try:
help_outlineHow to Useexpand_more

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 % b is 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.

infoWhat is Modulo Calculator?expand_more

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.

functionsFormulaexpand_more

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

lightbulbExamplesexpand_more

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

quizFAQexpand_more
What is the modulo operation used for in programming?expand_more
Modulo is used extensively in programming: checking if numbers are even/odd (n % 2), creating circular arrays and wrap-around effects, limiting values to a range, implementing hash functions, cycling through array indices, and time calculations (e.g., converting seconds to hours:minutes:seconds).
What happens when the divisor is larger than the dividend?expand_more
For positive numbers, when the divisor (modulus) is greater than the dividend, the remainder equals the dividend itself. For example, 5 mod 10 = 5 because 10 goes into 5 zero times with 5 left over.
How do I check if a number is a multiple of another?expand_more
Use modulo: if a mod b = 0, then a is a multiple of b. For example, to check if 496 is a multiple of 4: 496 mod 4 = 0, so yes. To check 226: 226 mod 4 = 2, so no, 226 is not a multiple of 4.
What's the difference between mod and % operators?expand_more
In most programming languages, % and mod are the same operation. However, they may handle negative numbers differently. JavaScript, Python, and most languages use % for modulo. The mathematical definition always returns a non-negative result when the divisor is positive.
Why does the result of modulo always less than the divisor?expand_more
The remainder must always be less than the divisor because if it were equal or greater, you could divide one more time. For 27 mod 6 = 3: the remainder 3 is less than 6. If it were 6 or more, you'd increase the quotient.