Solution (source code)

= Solution

Apply <Euler's criterion> to $-1$. It gives
$$
\boxed{\left(\frac{-1}{p}\right)=(-1)^{(p-1)/2}=\begin{cases}1,&p\equiv1\pmod4,\\-1,&p\equiv3\pmod4.\end{cases}}
$$
For $p\nmid ab$, the same criterion gives $(ab/p)\equiv (ab)^{(p-1)/2}=a^{(p-1)/2}b^{(p-1)/2}\equiv(a/p)(b/p)\pmod p$. Both sides are integers in $\{1,-1\}$, which are distinct modulo an odd prime, so congruence implies equality. This proves <multiplicativity of the Legendre symbol>:
$$
\boxed{\left(\frac{ab}{p}\right)=\left(\frac ap\right)\left(\frac bp\right).}
$$