Solution (source code)

= Solution

Write $N=\prod_i p_i^{e_i}$ with odd primes $p_i$. The <Jacobi symbol> is
$$
\left(\frac aN\right)=\prod_i\left(\frac a{p_i}\right)^{e_i},
$$
where each factor on the right is a Legendre symbol. The supplementary law is
$$
\left(\frac2N\right)=(-1)^{(N^2-1)/8}.
$$
For coprime positive odd $m,n$, <quadratic reciprocity> gives
$$
\left(\frac mn\right)\left(\frac nm\right)
=(-1)^{(m-1)(n-1)/4}.
$$
Applying this with $m=3$ gives
$$
\left(\frac3N\right)=
\begin{cases}
 1,&N\equiv1,11\pmod {12},\\
-1,&N\equiv5,7\pmod {12},\\
 0,&3\mid N.
\end{cases}
$$
Finally, factor $d=2^e m$ with $m$ odd. The supplementary laws for $-1$ and $2$, followed by reciprocity on every odd prime factor of $m$, express $(-d/a)$ solely in terms of the residue class of the positive odd integer $a$ modulo $d$ when $d\equiv0$ or $3\pmod4$. If $a\equiv b\pmod d$, all those factors, including the zero cases, agree; hence
$$
\boxed{\left(\frac{-d}{a}\right)=\left(\frac{-d}{b}\right).}
$$