CalcDomain
Home
/
Categories
/
Home › Math & Conversions › Core Math & Algebra › Modulo Modulo Calculator Compute a mod n, return the integer remainder of division, handle negative numbers, and check modular congruence. Includes a batch mode for modulo tables. Core Math & Algebra Interactive modulo and remainder calculator Use this tool to compute the remainder of integer division (a mod n), understand Euclidean division a = q·n + r, and verify congruences a ≡ b (mod n). The calculator always uses the Euclidean definition of modulo, so the remainder r is between 0 and n − 1 for n > 0, even if a is negative. Single value Batch list (table) Dividend a Integer to be divided You can enter positive or negative integers. Modulus n Positive integer divisor Must be a positive integer. The calculator enforces n > 0. Optional comparison b Check a ≡ b (mod n) Leave empty if you only need a single modulo result. List of integers Values a i (comma, space, or line separated) The tool will ignore empty entries. All values must be integers. Modulus n Positive integer divisor Ideal for building modulo tables or checking repeating patterns. Compute modulo Clear Load example Modulo result (single value) Valid input Dividend a Modulus n Quotient q Remainder r (a mod n) By Euclidean division: Range This calculator always returns r with 0 ≤ r < n. Congruence check a ≡ b (mod n) Comparison b a mod n b mod n Relation Modulo table (batch mode) Table generated Each row shows a value a i , the integer quotient q i , and the remainder r i = a i mod n. a i n q i r i = a i mod n Identity What is modulo? In arithmetic, the modulo (or mod ) operation returns the remainder when one integer is divided by another positive integer. When we write \[ a \bmod n, \] we mean the remainder r that appears in the Euclidean division of a by n: \[ a = q n + r, \quad \text{with } q \in \mathbb{Z},\; 0 \le r < n. \] For example, 17 mod 5 = 2 because 17 = 3 × 5 + 2 and 2 lies in the interval [0, 5). The calculator implements exactly this definition. Euclidean division and remainder For integers a and n > 0, Euclid's division theorem guarantees that there exist unique integers q (quotient) and r (remainder) such that: \[ a = q n + r \quad \text{and} \quad 0 \le r < n. \] In this calculator: You enter a and n as integers with n > 0. The tool solves for q and r. The displayed value of a mod n is exactly r. If a is negative, q will also be negative in such a way that r stays between 0 and n − 1. For instance, −7 mod 5 = 3 because −7 = (−2) × 5 + 3. Modulo with negative numbers When you compute modulo by hand or in pure math, the remainder is defined to be non-negative and less than n. However, some programming languages use a raw remainder operator that follows the sign of the dividend, which can create confusion when a is negative. This calculator always follows the Euclidean convention: \[ r = a - n \left\lfloor \frac{a}{n} \right\rfloor, \quad 0 \le r < n. \] That is why you may see results like −1 mod 5 = 4 or −7 mod 5 = 3. These are the standard values in modular arithmetic and make many theorems and identities work cleanly. Modular congruence a ≡ b (mod n) Two integers a and b are said to be congruent modulo n if they leave the same remainder when divided by n. Formally: \[ a \equiv b \pmod{n} \quad \Longleftrightarrow \quad n \mid (a - b) \quad \Longleftrightarrow \quad a \bmod n = b \bmod n. \] Typical examples: 17 ≡ 2 (mod 5), because both have remainder 2 mod 5. −1 ≡ 4 (mod 5), because −1 mod 5 = 4. 8 ≡ 0 (mod 4), because 4 divides 8 exactly. The congruence checker in this calculator compares a and b modulo n and reports whether they are congruent, including their canonical remainders. Practical uses of modulo Modulo arithmetic appears in many applications: Clock arithmetic: hours wrap around every 12 or 24. Computer science: hashing, cyclic buffers, and random number generators. Number theory: studying primes, residues, and patterns in integers. Scheduling and repetition: events occurring every n days, positions in cycles. The batch table mode helps you spot repeating patterns such as cycles of residues in these contexts. Modulo calculator – FAQ Can I use non-integer numbers in the modulo calculator? No. The standard definition of modulo is based on integer division, so this calculator requires that a and n be integers and n > 0. If you need floating-point remainders, consider scaling your values to integers or using a different tool tailored to real numbers. What happens if I enter n = 0? Division by zero is undefined, so modulo with n = 0 is also undefined. The calculator will return an error and ask you to choose a positive integer modulus instead. Why do some programming languages give a negative result for a % n? Many languages implement the % operator as a remainder that keeps the sign of a. For example, in some environments −7 % 5 = −2. Mathematically, however, it is often more convenient to use the Euclidean remainder 3. This tool uses the mathematical convention so that modular identities and congruence rules behave as expected. How large can the numbers be? The limit is essentially the range of standard JavaScript integers. For everyday modular arithmetic, cryptography exercises, and classroom examples, this range is more than sufficient. Extremely large inputs may lose precision due to the underlying floating-point representation. Can I export the modulo table? The batch table is designed for quick on-screen inspection. To export results, you can copy the table rows into a spreadsheet or text editor and convert them into CSV or another format suitable for your workflow. Frequently Asked Questions How should I interpret the quotient and remainder? The quotient q tells you how many whole copies of n fit inside a, while the remainder r tells you what is left over. Together they satisfy a = q·n + r with 0 ≤ r < n. The modulo result is simply this remainder r. Why does the calculator sometimes show large negative quotients? When a is negative, the quotient q may also be negative to keep the remainder r in the interval [0, n). This is normal in Euclidean division and does not affect the correctness of the modulo result. Is this calculator suitable for modular arithmetic in number theory? Yes. Because it enforces the Euclidean definition of remainder, the results are consistent with standard number theory textbooks and proofs. You can safely use it to check modular equations and congruences. Related Core Math & Algebra tools Explore more tools that support modular arithmetic, number theory, and core algebra. Set theory Interval notation Base converter Exponent Fibonacci number Prime number Euclidean algorithm Continued fraction Dice roll probability Vector Pythagorean theorem SOHCAHTOA (trigonometry) Grade calculator All Math & Conversions tools Modulo quick reference Euclidean division a = qn + r, 0 ≤ r < n Modulo a mod n = r Negative a r = a − n⌊a/n⌋ Congruence a ≡ b (mod n) ⇔ n | (a − b) Canonical range 0 ≤ a mod n < n Use these identities along with the calculator to verify hand calculations and better understand modular arithmetic.
/
General
General
Calculators in General.
Modulo Calculator
/modulo