# Modular Arithmetic Calculator (Add / Subtract / Multiply / Inverse / Power)

Exact BigInt modular arithmetic for values up to 10¹⁸: (a ± b) mod m, (a × b) mod m, a⁻¹ mod m via extended Euclid, and aᵇ mod m via fast exponentiation.

> Canonical page: https://elysiatools.com/en/tools/modulo-arithmetic-converter

- **Category:** Math & Numbers

- **Keywords:** modular arithmetic, modulo, mod, congruence, modular inverse, fast power, square and multiply, extended euclid, number theory, remainder

## Overview

The Modular Arithmetic Calculator performs exact BigInt modular calculations for integers up to 10¹⁸, including addition, subtraction, multiplication, modular inverse via the Extended Euclidean algorithm, and modular exponentiation using fast square-and-multiply.

## Inputs

- **Operation** (select)
- **Value a** (text): First operand (the base in power mode, the value being inverted in inverse mode).
- **Value b** (text): Second operand — the exponent in power mode; unused in inverse mode.
- **Modulus m** (text): Modulus, m ≥ 2. Results are reduced to the canonical range \[0, m−1\].

## When to use

- Computing modular inverses for cryptography homework or RSA key generation exercises.
- Evaluating large power congruences like aᵇ mod m without floating-point overflow.
- Solving discrete mathematics and number theory congruences in the canonical range \[0, m−1\].

## How it works

- Select the arithmetic operation: addition, subtraction, multiplication, inverse, or power.
- Enter operand a, modulus m (where m ≥ 2), and second operand or exponent b if required.
- The tool executes exact BigInt operations, applying Euclidean reduction or binary exponentiation step by step.
- Review the resulting congruence alongside intermediate reduction steps, Bézout coefficients, or bitwise decomposition.

## Use cases

- Verifying manual steps in number theory problem sets involving modular division and inverses.
- Demonstrating RSA cryptographic steps such as modular exponentiation and decryption key verification.
- Simplifying modular reductions for competitive programming challenges with large 64-bit moduli.

## Frequently asked questions

### What is the canonical form returned by the calculator?

All results are reduced to the standard non-negative residue range [0, m−1].

### When does a modular inverse exist?

A modular inverse a⁻¹ mod m exists if and only if gcd(a, m) = 1 (a and m are coprime).

### How does the tool handle large exponents?

It uses the binary square-and-multiply algorithm to compute aᵇ mod m in logarithmic time O(log b).

### Is there a limit on input number size?

The calculator uses exact BigInt arithmetic supporting values up to 10¹⁸ without precision loss.

### Why is operand b disabled or ignored in inverse mode?

Modular inversion only requires base a and modulus m to solve the Bézout identity a·x + m·y = 1.

## Related tools

- [Boolean Algebra Simplifier (Karnaugh Map)](https://elysiatools.com/en/tools/boolean-algebra-simplifier): Minimal SOP via Quine–McCluskey with essential prime implicants, exact minimum cover, Gray-coded Karnaugh map, and full-assignment verification.
- [Dilution Ratio Converter (1:X ↔ 1/X ↔ %)](https://elysiatools.com/en/tools/dilution-ratio-converter): Convert dilution notations 1:X ↔ 1/X ↔ percent, with dilution factor, parts, and mixing volumes.
- [Extended Euclidean Algorithm (ax + by = gcd(a, b))](https://elysiatools.com/en/tools/extended-euclidean-algorithm): Bézout coefficients for any-sign integers with the full division-step table, lcm, and optional linear Diophantine solving (particular + general solution).
- [Modular Inverse Calculator (Extended Euclidean Algorithm)](https://elysiatools.com/en/tools/modular-inverse-calculator): a⁻¹ mod m via extended Euclid with Bézout coefficients, an optional step table, and an a × a⁻¹ ≡ 1 (mod m) verification; RSA-sized inputs supported.
- [Truth Table Generator](https://elysiatools.com/en/tools/truth-table-generator): Complete truth table (≤ 6 variables, 64 rows) with alphabetical variable order, per-row function values, and canonical Σm/ΠM forms.
- [Angular Velocity Converter (rad/s / rpm / deg/s / Hz)](https://elysiatools.com/en/tools/angular-velocity-converter): Convert angular velocity (angular speed) between radian per second (rad/s, SI base), revolutions per minute (rpm = 2π/60 rad/s), degrees per second (deg/s = π/180 rad/s), and hertz (Hz, used as revolution per second = 2π rad/s). Converts via rad/s to the target unit and lists all four equivalents. Note: 1 Hz in angular-frequency context means one full revolution per second, so 1 Hz = 2π rad/s ≈ 6.283185307 rad/s. Reference: vinyl LP 33⅓ rpm ≈ 3.49 rad/s, car engine idle ~800 rpm ≈ 83.8 rad/s.
- [Duct Size Calculator (Flow Rate × Velocity)](https://elysiatools.com/en/tools/duct-size-calculator): Size a duct cross-section from the air flow rate Q and the design mean velocity v: area A = Q/v. Circular duct diameter D = √(4A/π). Rectangular duct with aspect ratio r = a/b gives b = √(A/r) and a = r·b, plus the ASHRAE equivalent diameter D_eq = 1.30·(a·b)^0.625/(a+b)^0.25. Flow rate in m³/s/m³/h/CFM, velocity in m/s; dimensions reported in mm and inches.
- [Fatigue Limit Calculator (Goodman / Gerber / Soderberg)](https://elysiatools.com/en/tools/fatigue-limit-calculator): Mean-stress fatigue correction under cyclic loading. Given stress amplitude σ_a, mean stress σ_m, and material σ_uts / σ_-1 (endurance limit) / σ_y, compute safety factors from three classical criteria: Modified Goodman (linear, conservative), Gerber (parabolic, better for ductile metals), and Soderberg (uses σ_y, most conservative). Reports the governing (smallest) value and whether the operating point lies inside the Goodman line.

## Samples

- [Web Image Processing Python Samples](https://elysiatools.com/en/samples/web-image-processing-python): Web Python image processing examples using PIL/Pillow including reading, saving, resizing, and format conversion
- [Android Image Processing Java Samples](https://elysiatools.com/en/samples/android-image-processing-java): Android Java image processing examples including reading/saving images, scaling, and format conversion
- [Android Image Processing Kotlin Samples](https://elysiatools.com/en/samples/android-image-processing-kotlin): Android Kotlin image processing examples including reading/saving images, scaling, and format conversion
- [Web Image Processing Rust Samples](https://elysiatools.com/en/samples/web-image-processing-rust): Web Rust image processing examples including image read/save, scaling, and format conversion
