Quadratic Residues Calculator
Free online quadratic residues calculator. Enter your values and get instant results with the formula, step-by-step working, a worked example and FAQs — everything runs locally in your browser on Calcton, no signup required.
中文版:二次剩余在线计算器
原理:若 x² ≡ a (mod p) 有解,称 a 是模 p 的二次剩余。欧拉判据:对奇素数 p,a^((p−1)/2) ≡ 1 则剩余、≡ −1 则非剩余——这就是勒让德符号 (a|p)。二次互反律把 (p|q) 与 (q|p) 联系起来(p、q 均为奇素数时 (p|q)(q|p) = (−1)^((p−1)(q−1)/4)),加上补律 (2|p) = (−1)^((p²−1)/8)(p ≡ ±1 mod 8 时为 1)。雅可比符号 (a|n) 把定义推广到奇合数 n,但它为 1 不能推出可解性。
步骤:输入 a 与奇模数 n。工具先检测 n 是否(大概率)素数:素数走欧拉判据给出勒让德符号,并在有解时返回最小平方根(p ≡ 3 mod 4 用公式 a^((p+1)/4),否则在 1..p−1 内搜索);合数走二次互反律递归的雅可比符号,并明确提示「伪剩余」风险。
示例:(3|7) = -1(3 是模 7 的非剩余);(2|7) = 1(3² = 9 ≡ 2);(5|13) = -1;(10|21) 的雅可比 = -1((10|3)(10|7) = 1·(−1));模 7 的平方根:x² ≡ 2 的解 x = 3 与 4。
注意事项:模数必须是奇数;合数分母上雅可比为 1 时可能无解(如 2 模 15 的雅可比为 1 但 x² ≡ 2 (mod 15) 无解),素性检测用费马概率式(卡迈克尔数会误报,参见素数分类工具);平方根搜索在 p 很大且 p ≡ 1 mod 4 时较慢(上限 10⁵);勒让德符号为 0 表示 p 整除 a。
相关:模运算工具给出同余的计算基础;欧拉函数与费马小定理工具支撑欧拉判据;原根工具把二次剩余扩展到指数表;中国剩余定理工具处理合数模数的分解求解。
How to use the Quadratic Residues Calculator
- Fill in the inputs with your own numbers — every field shows what it expects.
- The result updates instantly as you type; no "Calculate" click needed.
- Read the result card for the main figure, the step-by-step formula, and practical notes.
Frequently asked questions
Is the Quadratic Residues Calculator free?
Yes — all math calculators on Calcton are free, with no sign-up required. Your inputs are processed in your browser and never sent to a server.
Is there a Chinese version of this tool?
Yes. Use the Chinese version link above — it is the same calculator with the interface in Simplified Chinese.
References
Formulas and benchmarks used by this calculator follow these published sources.
KevinContent LeadCalcton Editorial Team · Last updated 2026-10-02
Kevin maintains Calcton's formula verification and content: every calculator cites the standard it implements, worked examples are recomputed programmatically, and health benchmarks follow WHO and international guidelines.
Related calculators
More in this category: Math calculators
About math calculators
Free online math calculators for algebra, statistics, number theory and everyday arithmetic — from quadratic equations and matrices to percentages, fractions and prime factorization, each with step-by-step formulas.