This calculator checks a congruence a ≡ b (mod n). Enter two whole numbers a and b and the modulus n; you get a mod n, b mod n and (a − b) mod n. The two numbers are congruent when the last result is 0.
Formula
a mod n = a − n × ⌊a ÷ n⌋, the remainder between 0 and n − 1. a ≡ b (mod n) exactly when n divides a − b, that is when (a − b) mod n = 0.
- a, b: whole numbers, positive or negative
- n: the modulus, a whole number of at least 1
- ⌊ ⌋ means round down
Worked Example
Is 47 ≡ 17 (mod 5)?
- 47 ÷ 5 = 9.4, rounded down 9, so 47 mod 5 = 47 − 45 = 2
- 17 ÷ 5 = 3.4, rounded down 3, so 17 mod 5 = 17 − 15 = 2
- (47 − 17) mod 5 = 30 mod 5 = 0
- The remainders match and the difference mod 5 is 0, so 47 ≡ 17 (mod 5).
How to read the result
Clock arithmetic is mod 12 (or 24), days of the week are mod 7, and check digits use mod 10 or mod 11. This calculator always returns a remainder from 0 to n − 1, which is the mathematician’s convention, so −7 mod 3 = 2.
Limits and common mistakes
- Enter whole numbers. Decimal inputs give a decimal “remainder” that has no meaning in congruences.
- Many programming languages give −1 for −7 % 3; this page gives 2.
- n = 1 makes every pair congruent.
Frequently Asked Questions
What is 100 mod 7?
2, because 7 × 14 = 98.
What does ≡ mean?
Congruent: same remainder after division by n.
What is −7 mod 3?
2, because −7 = 3 × (−3) + 2.
Is 0 a valid remainder?
Yes. a mod n = 0 means n divides a.
Formula used
in a | a | - | 47 | - in b | b | - | 17 | - in n | Modulus n | - | 5 | 1 out r | a mod n | - | a - n * floor(a / n) | 0 out rb | b mod n | - | b - n * floor(b / n) | 0 out dm | (a − b) mod n (0 = congruent) | - | (a - b) - n * floor((a - b) / n) | 0
Each line is one input (in, sel, list) or one result (out: label, unit, formula, decimals). How the calculators work
Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.
- How to Calculate Anniversary Years
- Minutes in a Leap Year: Calculator & Exact Count
- Digit Sum Calculator with Solution Steps
- Decimal Addition Calculator: Steps & Examples
- Adding and Subtracting Fractions Calculator: How It Works
- How to Calculate Consecutive Integers From Their Sum7.00