Basic Modulo and Remainder
Compare Euclidean, truncated, floored, and symmetric conventions.
Addition, Subtraction, Multiplication, Division, and Power
Modular Power Calculator
Supports huge exponents when GMP is installed.
Modular Inverse and Bézout Coefficients
Solve ax ≡ b (mod n)
Generalized Chinese Remainder Theorem
Enter matching comma-separated residue and modulus lists.
Congruence Checker
Complete and Reduced Residue Systems
Modular Sequence Generator
Modular Addition, Subtraction, Multiplication, and Power Tables
Number-Theory Toolkit
Prime factors, phi, Carmichael lambda, orders, primitive roots, and symbols.
Programming-Language Remainder Comparison
Modular Expression Evaluator
Integer Base Converter
Polynomial Remainder over Z/mZ
Enter coefficients from constant term upward.
Clock Arithmetic and Circular Indexing
Batch Modulo Calculator
Enter one dividend and modulus pair per line.
Saved Calculation History
History is stored locally after successful calculations.
Core Modulo Formula
Euclidean modulo
For positive n, the result satisfies 0 ≤ r < n. This convention gives one standard representative.
Modular inverse
The inverse exists exactly when gcd(a,n)=1. The extended Euclidean algorithm produces it.
Linear congruence
The equation ax ≡ b mod n is solvable when gcd(a,n) divides b.
Choose a Module and Enter Integers
- Select a calculator module from the left navigation.
- Enter the required integers, modulus, operation, or sequence settings.
- Press the calculation button to process the request server-side.
- Review the normalized result, verification details, and warnings.
- Copy, print, or export tabular steps as CSV or JSON.
Understanding Modular Arithmetic
Modular arithmetic studies numbers after division by a fixed modulus. The result represents a position inside a repeating cycle. Clock arithmetic is a familiar everyday example.
A remainder convention matters when negative numbers appear. Euclidean modulo returns a nonnegative representative for positive moduli. Many programming languages instead return a truncated remainder.
Congruence notation compares two integers using their difference. Numbers are congruent modulo n when n divides their difference. They therefore occupy the same residue class.
Why Modular Inverses Matter
Ordinary division is unavailable inside many modular systems. Division becomes multiplication by a modular inverse. That inverse exists only for values coprime with the modulus.
The extended Euclidean algorithm finds Bézout coefficients. Those coefficients express the greatest common divisor as a linear combination. One coefficient becomes the desired inverse after normalization.
Fast Modular Exponentiation
Directly computing a huge power wastes memory and processing time. Binary exponentiation repeatedly squares reduced values. Every intermediate value stays below the modulus.
This method supports cryptography, checksums, pseudorandom generators, and number theory. Negative exponents first require a modular inverse. The inverse must exist before exponentiation continues.
Chinese Remainder Systems
The Chinese Remainder Theorem combines several congruence conditions. Pairwise coprime moduli always produce one solution modulo their product. Generalized systems may also use non-coprime moduli.
Non-coprime systems require compatibility checks. Conflicting residues produce no common solution. Compatible equations combine into one larger repeating solution class.
Residue Systems and Units
A complete residue system contains one representative from every class. A reduced residue system contains only numbers coprime with the modulus. Its size equals Euler's totient value.
Units are precisely the invertible residues. Zero divisors are nonzero residues that multiply into zero. Modular multiplication tables make both structures visible.
Programming Behavior
The percent operator often means remainder rather than mathematical modulo. Positive operands usually hide this difference. Negative operands reveal different language rules.
Always normalize external results when an application requires nonnegative residues. A common formula is ((a % n) + n) % n. This is especially useful for circular array indexes.
Large Integer Support
This application automatically uses PHP's GMP extension when available. GMP allows integers far beyond native machine limits. Without GMP, large calculations remain limited by PHP integers.
Install and enable GMP for cryptographic-sized values. Native mode remains suitable for common educational problems. Server limits still protect the calculator from oversized requests.
Example Calculations
| Expression | Result | Purpose |
|---|---|---|
17 mod 5 | 2 | Basic remainder |
29 mod 6 | 5 | Quotient verification |
-17 mod 5 | 3 | Euclidean normalization |
2^20 mod 17 | 16 | Fast modular exponentiation |
7^-1 mod 26 | 15 | Modular inverse |
14x ≡ 30 mod 100 | Multiple solutions | Linear congruence |
x ≡ 2,3,2 mod 3,5,7 | 23 | CRT system |
Modulo Calculator FAQs
Can the modulus be zero?
No. Division and modulo by zero are undefined.
Why do negative results differ?
Languages use different quotient rounding rules for remainder operations.
When does an inverse exist?
An inverse exists when the value and modulus are coprime.
Can CRT use non-coprime moduli?
Yes. The generalized solver checks compatibility before combining equations.
Does it support huge integers?
Yes when PHP GMP is installed. Otherwise native integer limits apply.
Can I export calculations?
CSV, JSON, copy, and print-to-PDF workflows are included.
What is symmetric residue?
It chooses a representative near zero instead of always nonnegative.
What are zero divisors?
They are nonzero residues whose product can equal zero modulo n.
What does multiplicative order mean?
It is the smallest positive exponent producing one modulo n.
How are polynomial coefficients entered?
Enter them from constant term upward, separated by commas.
Is expression evaluation safe?
The custom parser rejects functions, variables, and unsupported characters.