GCD and Modular Arithmetic Calculator

Find GCDs, solve modular equations, compute inverses and powers, inspect Euclidean steps, and export clear number theory results for study and verification every time.

Ready to calculate

Choose a mode and enter values below.

Calculator inputs

Separate values with commas, spaces, or semicolons.

Formula used

gcd(a,b) uses repeated division. Bézout form is ax + by = gcd(a,b).

LCM uses LCM(a,b) = |ab| / gcd(a,b). Modular values use least nonnegative residues.

Linear congruences use ax ≡ b (mod n). A modular inverse exists when gcd(a,n) = 1.

How to use this calculator

  1. Select the number theory operation you need.
  2. Enter integers A, B, and modulus n when required.
  3. Use the list field for multiple-number GCD calculations.
  4. Select addition, subtraction, or multiplication for modular operations.
  5. Press Calculate and review the result above the form.
  6. Export the current result using CSV or PDF.

Example table

OperationInputResultKey idea
GCD48, 186Euclidean algorithm
LCM12, 1836|ab| ÷ gcd
Modulo29 mod 71Least nonnegative residue
Inverse17⁻¹ mod 4338Extended Euclidean algorithm
Power3¹⁰⁰ mod 74Fast modular exponentiation
Congruence6x ≡ 8 mod 14x ≡ 6, 13 mod 14Divide by gcd

Understanding GCD and Modular Arithmetic

The greatest common divisor identifies the largest integer dividing two values exactly. The Euclidean algorithm finds this divisor using repeated remainder calculations. Each division replaces a larger problem with a smaller one. This process finishes when the remainder becomes zero. The previous nonzero remainder is the required GCD. Extended Euclidean calculations add useful coefficients to that process. Those coefficients satisfy Bézout's identity for the entered integers. They also reveal modular inverses when the GCD equals one.

Working with modular values

Modular arithmetic studies integers through their remainders after division. It treats numbers with matching remainders as congruent values. For example, seventeen and five are congruent modulo twelve. Their difference equals twelve, which the modulus divides exactly. Modular addition and multiplication can reduce values before calculations. This keeps intermediate values smaller and easier to inspect. A modular inverse reverses multiplication within a chosen modulus. Such an inverse exists only for coprime values. The extended Euclidean algorithm provides the inverse efficiently. Modular exponentiation handles large powers through repeated squaring. This method avoids computing an enormous ordinary power first.

Solving congruences and checking results

A linear congruence has the form ax congruent b modulo n. Solutions depend on the GCD of a and n. A solution exists when that GCD divides b exactly. Dividing the equation by this common divisor simplifies it. The reduced coefficient then has an inverse under the smaller modulus. Multiplying by that inverse produces a base solution. Additional solutions follow by adding multiples of the reduced modulus. Congruence checking is even simpler and uses a difference test. Two integers are congruent when their difference divides by n. This calculator exposes each major step. It also reports coprimality and useful modulus information. CSV export supports record keeping and further analysis. PDF export creates a readable calculation summary for sharing. These tools make modular number theory calculations easier daily.

Frequently asked questions

What is the GCD?

The GCD is the largest positive integer dividing every selected integer without a remainder.

What does modulo mean?

Modulo returns the remainder class after division by a nonzero modulus.

Can I use negative integers?

Yes. GCD uses absolute values, while modular results are normalized to least nonnegative residues.

When does a modular inverse exist?

An inverse of a modulo n exists exactly when gcd(a,n) equals one.

Why is modulo zero invalid?

Division by zero is undefined, so a modulus of zero cannot define remainder classes.

What does coprime mean?

Two integers are coprime when their greatest common divisor equals one.

How does extended GCD help?

It returns coefficients x and y satisfying ax + by = gcd(a,b), enabling inverse calculations.

How are linear congruences solved?

The calculator checks divisibility by the GCD, reduces the equation, and applies a modular inverse.

Related Calculators

scientific notation to standard form calculatordecimal clock calculatornearest tenth rounding calculatorconvert to radical form calculatorakor to decimal calculatorarithmetic mean temperature differencearithmetic sequence satexponential arithmeticinteger arithmetic practicemodular arithmetic solver

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.