CalcWorldHub
Free online calculator · no signup

Square roots modulo an odd prime calculator

Find both square roots of a quadratic residue modulo an odd prime, or show that none exists.

4,000 tools
Square roots modulo an odd prime calculator — Integer residue, Odd prime modulus and calculation method
Square roots modulo an odd prime calculator: inputs and calculation method.

How to use this calculator

Find both square roots of a quadratic residue modulo an odd prime, or show that none exists.

  1. Enter Integer residue, Odd prime modulus. Match the units shown beside each field and review the result together with the assumptions below.
  2. Read the worked example below to check the expected input format and result.
  3. Compare another scenario by changing one input at a time. Use Reset to return to the starting values.
Calculation guide

Square roots modulo an odd prime explained

Modular square roots6, 7
Modular square roots: 6, 7 in the worked scenario.

A numerical walkthrough

Integer residue = 10; Odd prime modulus = 13.

  • Modular square roots: 6, 7

The model behind the numbers

Tonelli–Shanks modular square root

Modulus is tested by trial division within the entered billion limit; composite moduli are rejected..

What to enter

a — Integer residue
Integer residue. Enter a whole number.
p — Odd prime modulus
Odd prime modulus. Enter a whole number.

Interpreting the result

Modulus is tested by trial division within the entered billion limit; composite moduli are rejected.

Assumptions and limits

The method is for an odd prime modulus. A residue may have no square root; composite moduli require different handling, and the modulus p = 2 is outside this page’s stated domain.

Frequently asked questions

Why require a prime?

The algorithm relies on arithmetic in a prime field.

Can zero have one root?

Yes, only zero modulo a prime.

Does every number have a root?

No, nonresidues have none.

How do I use the Square roots modulo an odd prime calculator?

Enter Integer residue, Odd prime modulus. Match the units shown beside each field and review the result together with the assumptions below.

What is a worked example of Square roots modulo an odd prime?

Integer residue = 10; Odd prime modulus = 13. Modular square roots: 6, 7