Congruência Linear
- Created by
- Renato Passos, Eng. de Software
- Reviewed by
- Renato Passos, Eng. de Software
Last updated: Apr 18, 2026
About this calculator
The linear congruence calculator solves equations in the form ax ≡ b (mod m), where a, b, and m are integers. This type of equation is fundamental in number theory and cryptography. To find solutions, the calculator checks if the greatest common divisor (gcd) of a and m divides b. If so, the solution x is computed using the modular multiplicative inverse of a, adjusted according to the modulus.
It works by applying modular arithmetic techniques. First, it calculates gcd(a, m) using the Euclidean algorithm. If gcd(a, m) does not divide b, no solution exists. Otherwise, the equation is reduced using Bézout's identity, finding x = (b * inverse(a)) mod m. Solutions can be multiple, depending on the modulus and gcd.
Use this calculator for problems involving cycles, scheduling, or cryptographic systems. For instance, in periodic task programming or RSA key analysis. Be cautious with non-coprime a and m values: this can limit or invalidate solutions. Always simplify the equation before using the calculator.
It is essential to understand that linear congruence requires a and m to be positive integers. If gcd(a, m) does not divide b, the equation has no solution. The final result is x ≡ c (mod n), where n is m divided by gcd(a, m). Fractional values must be converted to integers before being entered into the calculator.
Frequently asked questions
When does a linear congruence ax ≡ b (mod m) have a solution?
A solution exists only if the greatest common divisor of a and m (gcd(a, m)) divides b. Use the Euclidean algorithm to verify this condition.
What to do if gcd(a, m) does not divide b?
If gcd(a, m) does not divide b, the congruence has no solution. Review the values of a, b, and m or adjust the equation.
How many solutions can a linear congruence have?
If a solution exists, there are infinitely many solutions congruent modulo n, where n is m divided by gcd(a, m). Example: x ≡ 3 mod 5 implies x = 3, 8, 13, etc.
Can I use fractions for a or b?
No. The calculator works only with integers. Convert fractions to integers by multiplying by a common denominator.