Solution (source code)

= Solution

For an <integer> $a$ and an <odd prime> $p$, the <Legendre symbol> is
$$
\boxed{\left(\frac ap\right)=\begin{cases}0,&p\mid a,\\1,&a\not\equiv0\pmod p\text{ and }a\text{ is a square modulo }p,\\-1,&a\text{ is not a square modulo }p.\end{cases}}
$$
The value one refers to a nonzero <quadratic residue>; divisibility by $p$ is recorded separately by zero.