Modular Arithmetic Calculator

Perform modular operations and solve number theory problems

mod
^ mod
mod
x ≡ (mod )

About Modular Arithmetic

Modular arithmetic is a system of arithmetic for integers where numbers "wrap around" when reaching a certain value called the modulus.

Basic Modular Operations

In modular arithmetic, we perform operations and then find the remainder when divided by the modulus.

(a + b) mod m = ((a mod m) + (b mod m)) mod m
(a - b) mod m = ((a mod m) - (b mod m) + m) mod m
(a × b) mod m = ((a mod m) × (b mod m)) mod m

Modular Exponentiation

Computing a^b mod m efficiently using the square-and-multiply algorithm.

a^b mod m

This is particularly useful in cryptography and number theory applications.

Modular Inverse

The modular inverse of a modulo m is a number x such that a×x ≡ 1 (mod m).

a × a^(-1) ≡ 1 (mod m)

The inverse exists if and only if gcd(a, m) = 1.

Linear Congruences

A linear congruence is an equation of the form ax ≡ b (mod m).

ax ≡ b (mod m)

Solutions exist if and only if gcd(a, m) divides b.

Applications

  • Cryptography (RSA, Diffie-Hellman)
  • Computer science (hash functions)
  • Number theory research
  • Calendar calculations
  • Check digit algorithms

Properties

  • Commutative: a + b ≡ b + a (mod m)
  • Associative: (a + b) + c ≡ a + (b + c) (mod m)
  • Distributive: a(b + c) ≡ ab + ac (mod m)
  • Identity: a + 0 ≡ a (mod m)