Maths & numbers

Jacobi symbol calculator with reciprocity steps

The Jacobi symbol compresses quadratic-residue information into −1, 0 or 1 without requiring a factorization of the odd denominator.

Your numbers

Signed integer, absolute value at most 10^100.
Odd integer from 1 through 10^100.

Calculated on your device. Your inputs aren’t sent to us.

Your result

Ready when you are

Enter your inputs and select Calculate.

Report an issue

Behind the numbers

How this calculation works

The Jacobi symbol compresses quadratic-residue information into −1, 0 or 1 without requiring a factorization of the odd denominator. The calculation repeatedly reduces the numerator, removes factors of two and swaps odd arguments using quadratic reciprocity. Every sign change is recorded. These reductions work with exact integers, so a hundred-digit input is not rounded into a neighboring number before its congruence classes are checked.

THE FORMULA(a/n)=∏ (a/p)^e for n=∏p^e; (2/n)=(−1)^((n²−1)/8), with quadratic reciprocity for odd arguments.

A worked example

For a=2 and n=15, removing the factor two contributes +1 because 15 is congruent to 7 modulo 8. The remaining numerator is 1, giving (2/15)=1. Directly squaring all residues modulo 15 produces only 0,1,4,6,9 and 10, however. Two is absent. This example deliberately shows why a positive Jacobi symbol is not a general square-root existence certificate.

Good to know

The denominator must be positive and odd. The numerator may be negative or zero; both arguments have absolute value at most 10^100. The convention (a/1)=1 includes (0/1). The result is a Jacobi symbol, not a Kronecker symbol for even denominators, a primality verdict, a factorization or a list of modular square roots.

Read the three possible answers correctly

A zero result means the numerator and denominator are not coprime, except for the explicitly stated denominator-one convention. If the odd denominator is prime and the numerator is not divisible by it, +1 means a nonzero quadratic residue and −1 means a nonresidue. For composite denominators, −1 still rules out a square root for a coprime numerator, but +1 can conceal incompatible local signs.

The example 2 modulo 15 has a negative Legendre symbol at both prime factors 3 and 5. Their product is positive, even though the congruence fails in each field separately. A square modulo 15 would have to be a square modulo both factors. Multiplying two signs therefore loses information needed for an existence decision. Use the modular-root page when actual roots over a supported prime modulus are required.

A positive Jacobi symbol can hide two negative prime-factor signs(2/3) = −1(2/5) = −1(2/15) = +1No square root modulo 15
For 2 modulo 15, the local Legendre signs at primes 3 and 5 are both −1. Their product is +1, yet neither local equation has a square root. The positive product is not a root certificate.

The Modular square root calculator for a prime modulus finds actual square roots over a prime field; a Jacobi sign for an odd composite denominator is a different kind of information.

Track reductions instead of guessing from the magnitude

Reducing a modulo n preserves the symbol. This includes negative a: the reduction chooses a residue from zero through n−1 before the loop starts. A factor of two changes the sign precisely when the current odd denominator is congruent to 3 or 5 modulo 8. Removing several twos applies that rule repeatedly, so an even number of identical flips cancels.

After the numerator becomes odd, exchanging numerator and denominator introduces a minus sign only when both are 3 modulo 4. The next remainder makes the problem smaller, just as in Euclid’s algorithm. The running sign and the eventual common-divisor case determine the answer. A trace containing no swaps can be entirely correct for a numerator that reduces immediately to zero or one.

Choose the right symbol for the denominator

Jacobi symbols extend the odd-prime Legendre symbol multiplicatively. They are useful in number theory because a factorization is unnecessary for evaluation, although prime factors explain their definition. That computational advantage does not turn the calculation into a factoring algorithm: the reduction trace is not claimed to reveal every prime divisor.

An even denominator changes the mathematical object. Some references define a Kronecker extension, but silently applying it here would make the input label misleading. This calculator rejects an even n rather than returning a result under an unstated extension. For n=1, the empty product gives one for every numerator; this convention is displayed so it is not confused with a coprimality failure.

A few questions, answered

Can +1 prove that a square root exists?

For an odd prime denominator and a nonzero residue, yes. For a composite denominator, no: 2 modulo 15 is the worked counterexample.

Why is a negative numerator allowed?

The symbol depends on the numerator residue class. Exact modular reduction converts a negative input to its equivalent nonnegative residue before reciprocity steps.

Find your calculator

Start typing to explore the library.