Solution (source code)

= Solution

For an odd <prime number> $p$ and an integer $n$ not divisible by $p$, the <Legendre symbol> $\chi(n)=(n/p)$ is $1$ if $n$ is a <quadratic residue> modulo $p$, and $-1$ otherwise. One may extend it by $\chi(n)=0$ when $p\mid n$.