Modular Arithmetic Calculator
Add, subtract, multiply and raise to a power modulo m, and find the modular inverse of a.
Runs in your browser. Your files never leave your device. See how to check
…
How to do it
- 1Step 1: Open Modular Arithmetic Calculator and add your input
Type your numbers or text, add your file, or pick the options you need. Nothing is uploaded: everything stays in your browser.
- 2Step 2: What Modular Arithmetic Calculator does
Add, subtract, multiply and raise to a power modulo m, and find the modular inverse of a.
- 3Step 3: Read the result and compare
The result appears at once. Change one value to see how the answer moves, then keep the figure that fits your case.
- 4Step 4: Copy or save it
Copy the result or download it. For an important decision, confirm it with the official source or an adviser.
About this tool
Enter two integers a and b and a modulus m. The calculator gives (a + b), (a − b), (a × b) and a^b, all mod m, plus gcd(a, m) and the modular inverse of a when it exists.
Modular inverse
The inverse of a mod m is the number x with a × x ≡ 1 (mod m). It exists only when gcd(a, m) = 1 and is found with the extended Euclidean algorithm. For example 17 × 2753 = 46801 = 15 × 3120 + 1, so 17⁻¹ ≡ 2753 (mod 3120).
Powers
The power is computed by repeated squaring, so even huge exponents are fast and exact. Results are always in the range 0 to m − 1, including for negative inputs. Whole numbers of any size are accepted (exact big-integer arithmetic).
Worked example
With a = 17, b = 5, m = 3120: sum 22, difference 12, product 85, 17^5 mod 3120 = 257, gcd 1 and inverse 2753. This is the RSA textbook example.
Tips for best results
Check every box before you rely on a result, because one wrong digit changes the whole answer. Use the exact figures from your payslip, bill, certificate or contract, and keep a note of the date you calculated. Rates, thresholds and rules change from time to time, so for tax, fees and legal matters treat the output as an estimate and confirm with the official source named on this page. You can run as many scenarios as you like; nothing is saved or sent, and refreshing the page clears the boxes.
Quick facts
- Category: Math & Science
- Works in your browser, no sign-up, no upload.
- Your input stays on your device.
- Available in many languages.
- Content last reviewed:
Frequently asked questions
When does an inverse exist?
Only when a and m have no common factor (gcd = 1).
Can I use negative numbers?
Yes. The result is always reduced to 0 … m − 1.
How big can the numbers be?
Any size; the arithmetic is exact.
Is a negative exponent supported?
The power row is left out for a negative b.
