KroneckerSymbol[n,m]
gives the Kronecker symbol
.
KroneckerSymbol
KroneckerSymbol[n,m]
gives the Kronecker symbol
.
Details
- KroneckerSymbol is also known as the Jacobi symbol or Legendre symbol.
- Integer mathematical function, suitable for both symbolic and numerical manipulation.
- KroneckerSymbol[n,1] gives 1.
- KroneckerSymbol[n,-1] gives 1 whenever n is non-negative and
otherwise. - For a number
with
a unit and
primes,
returns
.
Examples
open all close allBasic Examples (2)
KroneckerSymbol[17, 6]Table[KroneckerSymbol[n, m], {n, 5}, {m, 5}]Plot the KroneckerSymbol sequence with respect to the second argument:
DiscretePlot[KroneckerSymbol[7, m], {m, 50}]Scope (9)
Numerical Evaluation (3)
KroneckerSymbol works over integers:
KroneckerSymbol[10, 13]KroneckerSymbol[10 ^ 11 + 1, Prime[2000]]KroneckerSymbol threads elementwise over lists:
KroneckerSymbol[{2, 3, 5, 7, 11}, 6]Symbolic Manipulation (6)
TraditionalForm formatting:
KroneckerSymbol[n, m]//TraditionalFormReduce[KroneckerSymbol[p, 3] == 2 KroneckerSymbol[p + 1, 3] - 1 && -5 < p < 5, {p}, Integers]Solve[KroneckerSymbol[n, 5] == 1 && 0 < n < 5, n, Integers]Use KroneckerSymbol in a sum:
Sum[KroneckerSymbol[a, 16], a]DifferenceRootReduce[KroneckerSymbol[n, 7], n]GeneratingFunction[KroneckerSymbol[n, 7], n, x]Applications (11)
Basic Applications (2)
Table of values of the Kronecker symbol
with n, m up to 10:
Grid[Table[If[n m == 0 , If[n + m == 0, " ", Style[n + m, Red, Italic, Bold]], KroneckerSymbol[n, m]], {n, 0, 10}, {m, 0, 10}], ...]Plot the nontrivial values of the Kronecker symbol:
ArrayPlot[Table[KroneckerSymbol[n, m], {n, 0, 40}, {m, 1, 2n, 2}], ColorRules -> {1 -> Red, -1 -> Blue}]Number Theory (9)
For congruent integers m and n modulo p, KroneckerSymbol[m,p]==KroneckerSymbol[n,p]:
Mod[2, 7] == Mod[23, 7]KroneckerSymbol[2, 7] == KroneckerSymbol[23, 7]Find Euler–Jacobi pseudoprimes to base
: [more info]
pseudoPrimeQ[n_Integer] := GCD[n, 2] === 1 && CompositeQ[n] && KroneckerSymbol[2, n] == Mod[2 ^ ((n - 1) / 2), n];Select[Range[10000], pseudoPrimeQ]The law of quadratic reciprocity for distinct primes n and m
:
{n, m} = {11, 13};PrimeQ[{n, m}]KroneckerSymbol[n, m ]KroneckerSymbol[m, n] == (-1) ^ ((n - 1)(m - 1) / 4)Construct eigenvectors of the discrete Fourier transform:
With[{p = 13}, Table[KroneckerSymbol[k, p], {k, 0, p - 1}]]//NFourier[%]Evaluate Gauss sums in closed form:
GaussSum[h_, p_] := KroneckerSymbol[h, p] I^((p - 1/2))^2 Sqrt[p] - 1;GaussSum[4, 11]The congruence equation
has a solution if KroneckerSymbol[a,p] == 1:
KroneckerSymbol[2, 7]PowerMod[2, 1 / 2, 7]KroneckerSymbol[n,k] is a real DirichletCharacter modulo k for odd integers k:
Table[KroneckerSymbol[n, 5], {n, 0, 4}]Table[DirichletCharacter[5, 3, n], {n, 0, 4}]A real primitive character χ modulo k can be written in terms of KroneckerSymbol[χ[-1]k,n]:
Table[DirichletCharacter[7, 4, n], {n, 0, 6}]Table[KroneckerSymbol[DirichletCharacter[7, 4, -1] * 7, n], {n, 0, 6}]Nonprimitive real characters can be written in terms of KroneckerSymbol at integers coprime to k:
DirichletCharacter[12, 3, {1, 5, 7, 11}]KroneckerSymbol[-4, {1, 5, 7, 11}]KroneckerSymbol is the generalization of the Jacobi symbol for all integers:
jacobi[n_, m_] := KroneckerSymbol[n, m] /; (OddQ[m] && Positive[m]);Table[jacobi[2, m], {m, 1, 9}]Properties & Relations (5)
KroneckerSymbol gives
for non-coprime integers:
CoprimeQ[9, 12]KroneckerSymbol[9, 12]KroneckerSymbol is a completely multiplicative function for each argument:
KroneckerSymbol[3 4, 7] == KroneckerSymbol[3, 7]KroneckerSymbol[4, 7]KroneckerSymbol[3, 9 7] == KroneckerSymbol[3, 9]KroneckerSymbol[3, 7]The law of quadratic reciprocity for distinct primes n and m
:
{n, m} = {11, 13};PrimeQ[{n, m}]KroneckerSymbol[n, m] KroneckerSymbol[m, n] == (-1) ^ ((n - 1)(m - 1) / 4)Use KroneckerSymbol to compute real DirichletCharacter modulo k for odd integers k:
Table[KroneckerSymbol[n, 5], {n, 0, 4}]Table[DirichletCharacter[5, 3, n], {n, 0, 4}]Check that the following relation holds for any odd integer:
n = 39;
KroneckerSymbol[-1, n] == (-1)^(n - 1/2)Neat Examples (4)
The array plot of KroneckerSymbol:
ArrayPlot[Table[KroneckerSymbol[n, m], {n, -50, 50}, {m, -50, 50}], ColorRules -> {-1 -> Black, 0 -> White, 1 -> Blue}]Plot the arguments of the Fourier transform of KroneckerSymbol:
ArrayPlot[Arg[Fourier[Table[KroneckerSymbol[m, n], {m, 100}, {n, 100}]]], ColorFunction -> Hue]Successive differences of KroneckerSymbol modulo 2:
ArrayPlot[Mod[NestList[Differences, KroneckerSymbol[Range[100], 77], 100], 2]]Plot the Ulam spiral of KroneckerSymbol:
ulam[n_] := Partition[Permute[Range[n ^ 2], Accumulate[Take[Flatten[{{n ^ 2 + 1} / 2, Table
[(-1) ^ j i, {j, n}, {i, {-1, n}}, {j}]}], n ^ 2]]], n];ArrayPlot[KroneckerSymbol[70, ulam[125]], ColorFunction -> "BlueGreenYellow"]See Also
Related Guides
History
Text
Wolfram Research (2007), KroneckerSymbol, Wolfram Language function, https://reference.wolfram.com/language/ref/KroneckerSymbol.html.
CMS
Wolfram Language. 2007. "KroneckerSymbol." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/KroneckerSymbol.html.
APA
Wolfram Language. (2007). KroneckerSymbol. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/KroneckerSymbol.html
BibTeX
@misc{reference.wolfram_2026_kroneckersymbol, author="Wolfram Research", title="{KroneckerSymbol}", year="2007", howpublished="\url{https://reference.wolfram.com/language/ref/KroneckerSymbol.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_kroneckersymbol, organization={Wolfram Research}, title={KroneckerSymbol}, year={2007}, url={https://reference.wolfram.com/language/ref/KroneckerSymbol.html}, note=[Accessed: 13-June-2026]}