# Quadratic modular equation solver

This calculator can solve equations of the form **ax² + bx + c ≡ 0 (mod n)** where the integer unknown **x** is in the range **0 ≤ x < n**. In particular, it can find modular square roots by setting ** a = -1**,

**,**

`b`= 0**and**

`c`= number whose root we want to find**.**

`n`=`modulus`You can type numbers or numerical expressions on the input boxes at the left.

The calculator accepts numbers of up to 1000 digits, but notice that the modulus **n** should be factored (some large numbers cannot be factored in a reasonable amount of time). The factorization engine is the one used in the Elliptic Curve Method factorization applet, that uses the methods ECM and SIQS.

When **a** is not zero, the number of solutions depends on the number of distinct prime factor of the modulus, so if the modulus has many small prime factors (say more than 14), the program could run out of memory and it will not show any solution.

## Expressions

You can also enter expressions that use the following operators and parentheses:

**+**for addition**-**for subtraction*****for multiplication**/**for division**%**for remainder**^**or******for exponentiation**n!**: factorial**p#**: primorial (product of all primes less or equal than`p`).**B(n)**: Previous probable prime before`n`**F(n)**: Fibonacci number F_{n}**L(n)**: Lucas number L_{n}= F_{n-1}+ F_{n+1}**N(n)**: Next probable prime after`n`**P(n)**: Unrestricted Partition Number (number of decompositions of*n*into sums of integers without regard to order).**Gcd(m,n)**: Greatest common divisor of these two integers.**Modinv(m,n)**: inverse of`m`modulo`n`, only valid when gcd(m,n)=1.**Modpow(m,n,r)**: finds`m`^{n}modulo`r`.

You can use the prefix *0x* for hexadecimal numbers, for example 0x38 is equal to 56.

The exponentiation symbol is not present in some mobile devices, so two asterisks ** can by typed as the exponentiation operator.

## Source code

You can download the source of the current program and the old quadratic modular equation applet from GitHub. Notice that the source code is in C language and you need the Emscripten environment in order to generate Javascript.

Written by Dario Alpern. Last updated 25 July 2018.

If you find any error or you have a comment, please fill in the form.