Modulo Calculator

MODULO NUMBER THEORY MATHEMATICS
Share:

Compute a mod m, the GCD and Bézout coefficients, the modular inverse, and modular exponentiation a^b mod m — the arithmetic behind cryptography. Free, runs in your browser.

RT-MAT-027 · Mathematics

Modulo Calculator

Whole numbers only. a and m give the remainder, GCD, Bézout coefficients and modular inverse; add b for ab mod m.

Advertisement
After tool · AD-W1Responsive · Post-tool

How to Use the Modulo Calculator

Enter a value and modulus

Type a whole number a and the modulus m. The remainder of a divided by m appears straight away, always given as a value between 0 and m − 1.

See the GCD and Bézout identity

The calculator shows the greatest common divisor of a and m and the integers x and y that satisfy a·x + m·y = gcd, the heart of the extended Euclidean algorithm.

Find the modular inverse

If a and m are coprime, it gives the modular inverse of a — the number that multiplies a back to 1 mod m. Otherwise it explains that no inverse exists.

Raise to a power

Add an exponent b to compute ab mod m by fast modular exponentiation — the operation at the core of RSA and Diffie–Hellman cryptography.

Advertisement
After how-to · AD-W2Responsive

Modular Arithmetic: Clock Maths

Numbers That Wrap Around

Modular arithmetic is the mathematics of remainders — the system you already use every time you read a clock. If it is 10 o'clock and you add five hours, you do not say 15 o'clock; you wrap around to 3. That is arithmetic modulo 12, and the same wrapping idea, applied to any modulus, turns out to be one of the deepest and most useful ideas in number theory. The basic operation is "a mod m", the remainder when a is divided by m, and this calculator always returns it in its natural range from 0 to m − 1, even for negative inputs — so −1 mod 26 is 25, not −1, exactly as the theory requires. From this single notion grow the tools that secure the modern internet. The calculator also computes the greatest common divisor of two numbers and, through the extended Euclidean algorithm, the Bézout coefficients: the integers x and y for which a·x + m·y equals that gcd. That identity is not a curiosity — it is precisely how a modular inverse is found.

The modular inverse is the modular world's version of division. In ordinary arithmetic, the inverse of a number is what you multiply it by to get 1; modulo m, the inverse of a is the number that multiplies a back to 1 mod m. It exists exactly when a and m share no common factor — when their gcd is 1 — and the extended Euclidean algorithm hands it to you directly. This is the engine behind a great deal of cryptography. The other pillar is modular exponentiation: raising a number to a power and taking the remainder, written a^b mod m, which this calculator computes even for large exponents using fast repeated squaring rather than multiplying b times. The reason this matters is a beautiful asymmetry. Computing a^b mod m is quick, but reversing it — finding b from the result, the so-called discrete logarithm — is believed to be astronomically hard. That one-way property is the foundation of RSA, Diffie–Hellman key exchange, and much of the encryption protecting your messages and payments. Everything here is computed in your browser with a small, deterministic engine.

"Modular arithmetic is clock maths: numbers wrap around a fixed cycle. Easy to compute forwards, hard to reverse — which is exactly why it secures the internet."

Where Remainders Run the World

Modular arithmetic is quietly everywhere. Every checksum and error-detecting code — the last digit of an ISBN, a credit-card number's Luhn check, the CRC that guards a network packet — is a modular calculation that catches typos and corruption. Hash tables, the data structure behind almost every fast lookup in software, map keys into buckets with a modulo operation. Random-number generators, calendar calculations that find the day of the week for any date, and the scheduling of repeating events all lean on wrapping arithmetic. And in cryptography it is foundational: the modular inverse and modular exponentiation this tool computes are the literal operations performed when your browser establishes a secure connection. Beyond the applications, modular arithmetic is where many students first meet the elegance of number theory — the surprising fact that remainders obey their own consistent, powerful algebra. Whether you are studying number theory, exploring how encryption works, computing a checksum, or just curious about clock arithmetic, this calculator gives you the remainder, gcd, Bézout coefficients, modular inverse and modular power at once, instantly and privately.

10 Facts About Modular Arithmetic

01

Modular arithmetic is clock maths — numbers wrap around a fixed cycle.

02

a mod m is the remainder, always taken between 0 and m − 1.

03

A modular inverse exists only when a and m are coprime.

04

The extended Euclidean algorithm finds the inverse and Bézout coefficients.

05

Modular exponentiation is fast forwards but hard to reverse.

06

That one-way property underpins RSA and Diffie–Hellman.

07

An ISBN check digit is a modular calculation.

08

Hash tables place keys into buckets using modulo.

09

Gauss introduced the congruence notation in 1801.

10

This calculator runs in your browser — nothing is uploaded.

Frequently Asked Questions

  • It is the remainder when a is divided by m. This calculator returns it in the standard range from 0 to m − 1, so the answer is always non-negative — for example, −1 mod 26 is 25. That is the convention used throughout number theory.
  • It uses the Euclidean definition, which always gives a non-negative remainder between 0 and m − 1. This differs from the sign-of-the-dividend behaviour of the % operator in some programming languages, and it is the mathematically standard choice.
  • The modular inverse of a (mod m) is the number x for which a·x ≡ 1 (mod m) — the modular equivalent of dividing. It exists only when a and m are coprime, that is, when their greatest common divisor is 1. The calculator finds it with the extended Euclidean algorithm.
  • For any two integers a and m, there are integers x and y with a·x + m·y = gcd(a, m). Those x and y are the Bézout coefficients, produced by the extended Euclidean algorithm. When the gcd is 1, the coefficient x is exactly the modular inverse of a.
  • It is computing a^b mod m — raising a to a power and taking the remainder. The calculator uses fast repeated squaring, so even large exponents are handled quickly without multiplying b times. It is the core operation of RSA and Diffie–Hellman cryptography.
  • Because some modular operations are easy one way and very hard to reverse. Computing a^b mod m is fast, but recovering b from the result — the discrete logarithm — is believed to be infeasible for large numbers. This asymmetry is what makes public-key encryption secure.
  • Yes, when a modular inverse exists. A negative exponent is interpreted as a power of the inverse — a^(−b) mod m means (a⁻¹)^b mod m. If a has no inverse modulo m, the calculator explains that the negative power is undefined.
  • In checksums and error detection (ISBN, credit-card Luhn checks, CRC codes), in hash tables that power fast lookups, in random-number generators, and in calendar calculations such as finding the day of the week. Anywhere numbers need to wrap around a fixed cycle, modular arithmetic is at work.
  • No. Every calculation runs in your browser with a small built-in engine — nothing is uploaded to a server or third-party library, and the tool works offline once the page has loaded.
  • Completely free, with no account, sign-up, or usage limit. It runs entirely in your browser and collects no data. Use it as much as you like.

Related News

You may be interested in these recent stories from our newsroom.

No related news yet for this tool. Our editorial team publishes new pieces every week.

Browse all news →
Advertisement
Pre-footer · AD-W3 728 × 90

75 more free tools

Calculators, converters, security tools — no signup.