🌐 EN

Modulo Calculator

Modular addition, subtraction, multiplication, exponentiation, inverse. Learn modular operations used in RSA cryptography.

Basic Modulo Modular Addition Modular Subtraction Modular Multiplication Modular Exponentiation Modular Inverse
GUIDE

Learn more

01

Modulo Operation Basics

Modulo operation (a mod m) is the remainder when a is divided by m. Example: 17 mod 5 = 2. Used daily in clock calculations (24-hour), day of week calculations. Essential in programming for array index wrapping, hash functions.

02

Modular Addition and Multiplication

Modular addition: (a + b) mod m. Modular multiplication: (a × b) mod m. To prevent overflow in large number calculations, take modulo at each step. Example: (12 + 8) mod 5 = 20 mod 5 = 0.

03

Modular Exponentiation - Fast Computation

When calculating a^b mod m, direct exponentiation makes numbers too large. Using divide-and-conquer fast exponentiation algorithm enables O(log b) time calculation. Core operation of RSA encryption.

04

Modular Inverse - Extended Euclidean Algorithm

Modular inverse is x such that (a × x) mod m = 1. Exists only when a and m are coprime. Calculated in O(log m) time using Extended Euclidean Algorithm. Used in decryption, fraction calculations.

05

RSA Cryptography and Modular Operations

RSA is a public-key cryptosystem based on modular exponentiation and inverse. Encryption: c = m^e mod n, Decryption: m = c^d mod n. Relies on the difficulty of factoring n, the product of two large primes.

Frequently asked questions

What happens when I compute modulo with a negative number?
Conventions for negative modulo vary by language, but this calculator follows the mathematical definition where the result is always between 0 and m-1. Example: -7 mod 5 = 3.
What if I enter 0 as the modulus (m)?
Division by zero is undefined, so a modulus of 0 cannot be calculated. The modulus m must be a positive integer.
When does a modular inverse not exist?
A modular inverse exists only when a and m are coprime, meaning their greatest common divisor is 1. For example, if both a and m are even, no inverse exists.
Why is a fast algorithm needed for modular exponentiation?
As the exponent grows, a^b becomes astronomically large, making direct computation impractical. Fast exponentiation (divide-and-conquer) applies the modulo at each step to keep numbers small, computing the result in O(log b) time.
Where is modular arithmetic used in practice?
It powers hash table bucket indexing, cyclic scheduling (days of week, clock time), encryption/decryption in RSA and other public-key systems, and checksum validation such as ISBN checks.