Modular Arithmetic Calculator Formula
Understand the math behind the modular arithmetic calculator. Each variable explained with a worked example.
Formulas Used
A Mod M
a_mod_m = mod(a, m)B Mod M
b_mod_m = mod(b, m)Add Mod
add_mod = mod(a + b, m)Mult Mod
mult_mod = mod(a * b, m)Quotient
quotient = floor(a / m)Variables
| Variable | Description | Default |
|---|---|---|
a | Number (a) | 17 |
m | Modulus (m) | 5 |
b | Second Number (b) | 8 |
How It Works
Modular Arithmetic
Definition
a mod m gives the remainder when a is divided by m.
For example, 17 mod 5 = 2 because 17 = 3 × 5 + 2.
Key Properties
Applications
Modular arithmetic is used in cryptography (RSA), hash functions, clock arithmetic, and check digit algorithms (ISBN, credit cards).
Worked Example
Calculate modular operations with a = 17, b = 8, m = 5.
a = 17m = 5b = 8
- 0117 mod 5 = 2 (17 = 3×5 + 2)
- 028 mod 5 = 3 (8 = 1×5 + 3)
- 03(17+8) mod 5 = 25 mod 5 = 0
- 04(17×8) mod 5 = 136 mod 5 = 1
Ready to run the numbers?
Open Modular Arithmetic Calculator