Residue Class Calculator

Explore residue classes, congruence checks, inverses, and modular powers. See tables, graphs, and exportable results. Practice modular arithmetic faster with clear guided outputs today.

Calculator

Enter values below to analyze a residue class, test congruence, perform modular operations, and generate exportable results.

Example data table

a n b c e Normalized residue Congruence check
29 12 53 7 5 5 29 ≡ 53 (mod 12)
-17 9 1 4 3 1 -17 ≡ 1 (mod 9)
42 11 9 8 4 9 42 ≡ 9 (mod 11)
35 8 3 6 2 3 35 ≡ 3 (mod 8)

Formula used

1) Normalized residue

r = ((a mod n) + n) mod n

This keeps the residue inside the standard set {0, 1, 2, ..., n − 1}, even when a is negative.

2) Congruence test

a ≡ b (mod n) if and only if n | (a − b).

Equivalently, a and b are congruent when they share the same normalized residue modulo n.

3) Residue class pattern

[a]n = {a + kn : k ∈ ℤ}

Every number in the class differs from a by a multiple of n, so all representatives reduce to the same residue.

4) Modular inverse

a-1 mod n exists only when gcd(a, n) = 1.

When it exists, the inverse x satisfies ax ≡ 1 (mod n).

5) Modular power

ae mod n

The calculator uses repeated squaring, which is faster than multiplying a by itself e times.

6) Class operations

[a] + [c] = [a + c], [a] − [c] = [a − c], and [a][c] = [ac] modulo n.

These operations are performed using the same modulus, then reduced to the standard residue range.

How to use this calculator

Step 1

Enter the main integer a and a positive modulus n. These two values define the residue class you want to study.

Step 2

Optionally enter b to test congruence with a, and c to perform modular addition, subtraction, and multiplication.

Step 3

Set the exponent e for a power result, choose how many class representatives to display, and select graph points.

Step 4

Click the calculate button. The result appears above the form, directly below the header, exactly as requested.

Step 5

Review the summary table, class representatives, inverse information, power output, and the residue cycle graph.

Step 6

Use the CSV and PDF buttons to export the result set for homework, teaching notes, or reference sheets.

Frequently asked questions

1) What is a residue class?

A residue class groups all integers that leave the same remainder when divided by the same modulus. For example, 5, 17, and 29 belong to the same class modulo 12 because each reduces to residue 5.

2) Why does the calculator show a normalized residue?

Normalized residues stay within the standard range from 0 to n − 1. This makes comparisons easier, especially when the original number is negative or much larger than the modulus.

3) What does a ≡ b (mod n) mean?

It means a and b differ by a multiple of n. Another way to say it is that both numbers reduce to the same residue after division by n.

4) Can I use negative integers?

Yes. The calculator accepts negative numbers and converts them into standard residues automatically. This is useful for algebra, number theory, and cryptography practice.

5) When does a modular inverse exist?

A modular inverse exists only when the integer and modulus are coprime. In practical terms, gcd(a, n) must equal 1. Otherwise, no multiplicative inverse exists modulo n.

6) What does the graph represent?

The graph plots integers against their residues modulo n. It helps you see the repeating cycle of modular arithmetic and quickly understand periodic residue behavior.

7) Why are several representatives shown for one class?

A residue class contains infinitely many representatives. Showing nearby values such as r − 2n, r − n, r, r + n, and r + 2n makes the class pattern easier to understand.

8) What can the exports be used for?

The CSV file is convenient for spreadsheets and datasets. The PDF file is useful for handouts, notes, tutorials, assignment solutions, and record keeping.

Related Calculators

tensor product calculatordirect product calculatorgroebner basis calculatorlocalization calculatordirect sum calculatorquotient ring calculatorprincipal ideal generatorcongruence relation calculatorproduct of formal power seriesinverse residue class calculator

Important Note: All the Calculators listed in this site are for educational purpose only and we do not guarentee the accuracy of results. Please do consult with other sources as well.