b2KIT

Modular Arithmetic Calculator

Compute modular addition, multiplication, exponentiation, and inverses. Visualize on clock-face number circles.

Tested tool guide Tested browser tools Checked August 16, 2026

What Modular Arithmetic Calculator does, with a checked example

Modular Arithmetic Calculator reduces addition, multiplication, exponentiation, and multiplicative inverses to residues for a chosen modulus. Enter the operands required by the selected operation and the modulus; the numerical result is accompanied by a clock-face number circle showing wraparound among residue classes. It answers questions such as where a power lands on a finite cycle. The important trap is the inverse: division modulo n is not ordinary division, and an input has no multiplicative inverse unless it is coprime to n.

Worked example

A concrete input and expected output from the current implementation.

Input

Operation: exponentiation
Base: 3
Exponent: 4
Modulus: 7

Expected output

4

The ordinary power is 3^4 = 81. Since 81 = 7 * 11 + 4, its residue modulo 7 is 4.

How the result is produced

1

Reducing operations

For a positive modulus n, addition returns the residue of a + b, multiplication returns the residue of a * b, and exponentiation returns the residue of a^e. Reducing operands before an operation does not change the final congruence. For example, 17 can be replaced by 2 in arithmetic modulo 5 because both leave residue 2.

2

Inverses and number circles

An inverse request looks for a residue x such that a * x has residue 1 modulo n. Such an x exists exactly when gcd(a, n) = 1. The number circle places residues around one cycle, with 0 following n - 1, so integers separated by a multiple of n occupy the same position.

Good uses

  • Check a cyclic schedule calculation, such as adding an offset to an hour on a 24-position cycle, and inspect where the result wraps around.
  • Work through a small textbook cryptography exercise that calls for modular exponentiation or the multiplicative inverse of an integer.
  • Verify a number-theory or programming calculation by checking whether two expressions produce the same residue under one specified modulus.

Limits and checks

  • A displayed residue does not preserve the quotient or the number of completed cycles. For example, 18 and 4 both produce residue 4 modulo 7.
  • A nonzero value can lack an inverse. If the value and modulus share a factor greater than 1, an inverse result cannot be produced.
  • Congruence depends on the selected modulus. Two values that occupy the same point modulo 7 may occupy different points after the modulus is changed.

Common questions

Why does a modular inverse sometimes not exist?

An inverse of a modulo n must multiply by a to produce residue 1. This is possible exactly when a and n have greatest common divisor 1. For example, 3 has inverse 5 modulo 7 because 3 * 5 = 15 has residue 1. The value 6 has no inverse modulo 9 because their greatest common divisor is 3.

Can this calculator solve every modular congruence?

No. It is scoped to modular addition, multiplication, exponentiation, and the inverse of one value. When a is invertible modulo n, a congruence such as a * x having residue b can be solved by multiplying b by that inverse. If a is not invertible, that shortcut is unavailable, and the congruence may have multiple solutions or no solution.

References and verification

The example and behavioral notes were checked against the browser implementation. Standards and primary references below define the relevant format, formula, or platform behavior.

Related Tools