Linear Congruence Solver

Solve a·x≡b (mod m) exactly, returning a residue, solution period, and number of residues modulo m; unsatisfiable equations return zero certificate fields.

Description

A linear congruence can have no solution, one residue class or several residues modulo m.

A linear congruence can have no solution, one residue class or several residues modulo m. The gcd of its coefficient and modulus determines solvability and multiplicity.1

The tool returns solvable, residue, period, multiplicity. The indexing and output conventions below determine how to read these values.

When to use Linear Congruence Solver

Use this for the following task: Solve a·x≡b (mod m) exactly, returning a residue, solution period, and number of residues modulo m; unsatisfiable equations return zero certificate fields. Use the input and output conventions below to reproduce the intended mathematical quantity.

How to use Linear Congruence Solver and understand its results

  1. Choose the required indexes, integers or sequence entries. Preserve decimal-string encodings where the field table specifies strings.
  2. Enter a, b, modulus according to the field table, then run the tool.
  3. Read solvable, residue, period, multiplicity. Preserve exact decimal strings and the stated indexing or coefficient order.
  4. Keep exact decimal strings for subsequent integer arithmetic; distinguish them from any explicitly approximate numeric result.
Input fieldMeaningValue type and boundsRequirement
aSigned coefficientstring (integer/arbitrary); maximum text length 200; pattern ^-?(0|[1-9][0-9]*)$Required
bSigned right-hand sidestring (integer/arbitrary); maximum text length 200; pattern ^-?(0|[1-9][0-9]*)$Required
modulusPositive modulusstring (integer/arbitrary); maximum text length 200; pattern ^[1-9][0-9]*$Required

Parse signed a and b and a positive modulus with BigInt. Use extended Euclid to find a normalized residue and return its period and multiplicity as strings.

a×x≡b mod m is solvable iff gcd(a,m)|b; period=m/gcd(a,m)

The symbols and boundary conditions refer to the supplied fields and the implementation described above.

Output fieldMeaningValue type
solvableWhether the congruence has a solutionboolean
residueLeast nonnegative solutionstring (integer/arbitrary)
periodPeriod of all solutionsstring (integer/arbitrary)
multiplicityNumber of solutions modulo the modulusstring (integer/arbitrary)
json
{
  "input": {
    "a": "14",
    "b": "30",
    "modulus": "100"
  },
  "output": {
    "solvable": true,
    "residue": "45",
    "period": "50",
    "multiplicity": "2"
  }
}

Limitations and assumptions

All solutions are residue+j×period for j=0..multiplicity−1 modulo m. An unsatisfiable equation returns solvable=false and zero certificate fields; modulus one is allowed.

Use the declared integer bounds and string formats. Large exact outputs remain decimal strings; numerical approximations use ordinary floating-point arithmetic. A rejected input is different from a valid zero count or false membership flag.

Alternative or Complementary methods

Choose Modular Inverse when you need its operation: Find the least nonnegative inverse of a signed decimal integer modulo a decimal modulus of at least two, rejecting noncoprime pairs. Choose Extended Euclidean Coefficients for the complementary operation: Find exact decimal coefficients x and y satisfying a·x+b·y=gcd(a,b), with a nonnegative gcd and deterministic coefficients even when both inputs are zero.

Background reference: Linear Congruences.

References

  1. Linear Congruences — Mount Royal University, Mathematics LibreTexts

Similar or alternative tools

  • Modular Inverse

    Find the least nonnegative inverse of a signed decimal integer modulo a decimal modulus of at least two, rejecting noncoprime pairs.

  • Extended Euclidean Coefficients

    Find exact decimal coefficients x and y satisfying a·x+b·y=gcd(a,b), with a nonnegative gcd and deterministic coefficients even when both inputs are zero.

Don't forget to set a bookmark for tool.io!
Privacy | Imprint | Cookies