Jacobi Symbol Calculator
Compute the Jacobi symbol for a number and an odd positive modulus from its prime factors.
What it does
The Jacobi symbol extends the Legendre symbol from prime moduli to odd positive composite moduli. It is defined by factoring the modulus and multiplying the Legendre symbols for each prime factor. It is a tool for computation and for algorithms such as primality testing, rather than a direct statement about square roots when the modulus is composite.
The Legendre symbol for an odd prime is one when the numerator is a quadratic residue, minus one when it is not and zero when the prime divides the numerator. The Jacobi symbol uses exactly those values and multiplies them. If a prime appears more than once in the factorization, its symbol is multiplied that many times.
For n equal to 15, the prime factors are 3 and 5. The Legendre symbol of 2 modulo 3 is minus one, and the symbol of 2 modulo 5 is also minus one. Their product is plus one, so the Jacobi symbol is plus one. The tool prints the factorization so you can follow each step.
The main warning is interpretation. For a prime modulus, a Jacobi symbol of plus one really does mean the numerator is a square. For a composite modulus it does not. The numerator 2 has Jacobi symbol plus one modulo 9, yet 2 is not a square modulo 9. A plus one result only tells you that an even number of prime factors see the numerator as nonresidues.
The tool accepts odd positive moduli up to one million and any integer numerator. Even moduli are outside this definition and are rejected. For those, a different extension called the Kronecker symbol is needed, which this page does not implement.
How to use
- Enter the numerator as any whole number.
- Enter an odd positive modulus between 3 and 1,000,000.
- Read the factorization of the modulus.
- Check the Legendre symbol contributed by each prime factor.
- Read the product, which is the Jacobi symbol.
- If the modulus is composite, do not read plus one as proof of a square root.
Formula
- a
- The numerator, reduced modulo each prime factor.
- n
- An odd positive modulus, which may be composite.
- p_i
- The ith distinct prime factor of n.
- e_i
- The multiplicity of that prime factor.
- (a/p_i)
- The Legendre symbol at the prime p_i.
The symbol is zero when any prime factor divides the numerator. Otherwise each factor contributes plus or minus one, and the product is plus or minus one. Because repeated factors are counted, the symbol modulo a square is always plus one for a numerator coprime to that square.
Worked example
Example: 2 over 15
Defaults: a = 2 and n = 15.
- Factor the modulus: 15 = 3 x 5.
- The Legendre symbol of 2 modulo 3 is minus one.
- The Legendre symbol of 2 modulo 5 is minus one.
- Multiply the contributions: minus one times minus one is plus one.
- The tool shows symbol 1, factorization 3 x 5 and the product description.
Reference table
| Numerator | Modulus | Jacobi symbol |
|---|---|---|
| 2 | 7 | 1 |
| 3 | 7 | -1 |
| 2 | 9 | 1 |
| 2 | 15 | 1 |
| 4 | 15 | 1 |
Limits
- Requires an odd positive modulus, so even values are rejected.
- A plus one result for composite n does not guarantee a quadratic residue.
- Does not implement the Kronecker symbol for even moduli.
- The modulus is limited to 1,000,000 to keep factoring fast.
Common mistakes
- Reading a Jacobi symbol of plus one as proof that a square root exists.
- Entering an even modulus, which is outside this definition.
- Forgetting to count repeated prime factors more than once.
- Confusing the Jacobi symbol with the greatest common divisor.
- Assuming a zero result only occurs when the numerator equals the modulus.
Try it yourself
Quick checks. Answers sit tucked under each question.
What does the tool show for a = 2 and n = 9?
The factorization is 3 x 3. Each Legendre symbol is minus one, so their product is plus one. The tool shows symbol 1 even though 2 is not a square modulo 9.
What happens for a = 3 and n = 15?
Since 3 divides 15, one Legendre factor is zero. The product is zero, so the tool reports Divisible by a factor of n.
Find the symbol of 4 over 15.
The factors are 3 and 5. Both see 4 as a square and give plus one, so the product is plus one.
Questions
What is the Jacobi symbol?
It is a generalization of the Legendre symbol to odd positive composite moduli, defined as a product of Legendre symbols over the prime factors.
How does it differ from the Legendre symbol?
The Legendre symbol is defined only for odd primes and predicts residues. The Jacobi symbol allows composite moduli but loses that direct meaning.
Why does plus one not prove a square?
A nonresidue modulo two different prime factors can give minus one times minus one, which is plus one, even though no square root exists for the composite modulus.
What does a zero result mean?
The numerator shares at least one prime factor with the modulus, so one of the Legendre factors is zero.
Can I use an even modulus?
No. Even moduli need the Kronecker symbol, which this calculator does not implement.
Why is the symbol useful?
It is used in primality tests and in algorithms that need a multiplicative character without factoring being required in theory, though this tool factors to show the steps.