# Value at 2 of a certain Dirichlet character defined by Jacobi symbol

Let $D$ be a non-square integer such that $D \equiv 1$ (mod $4$). Let $\chi\colon (\mathbb{Z}/D\mathbb{Z})^\times\rightarrow \mathbb{Z}^\times = \{-1, 1\}$ be the map defined in this question. Let $n$ be an integer. We denote by $[n]$, the image of $n$ by the canonical map $\mathbb{Z} \rightarrow \mathbb{Z}/D\mathbb{Z}$. Computing values of $\chi$ at $[2]$ for several $D$s, it seems that $\chi([2]) = 1$ if $D \equiv 1$ (mod $8$) and $\chi([2]) = -1$ if $D \equiv 5$ (mod $8$).

Is this true? If yes, how can we prove it?

We will freely use the properties of the Jacobi symbol as stated in this question In particular we have the folowing:

If $m \equiv 1$ (mod $4$), $\left(\frac{m}{n}\right) = \left(\frac{n}{m}\right)$.

If $m \equiv 3$ (mod $4$) and $n \equiv 3$ (mod $4$), $\left(\frac{m}{n}\right) = -\left(\frac{n}{m}\right)$.

If $m \equiv 1$ (mod $4$), $\left(\frac{-1}{m}\right) = 1$.

If $m \equiv 3$ (mod $4$), $\left(\frac{-1}{m}\right) = -1$.

Case 1 $D \gt 0$

$\chi([2]) = \chi([D + 2]) = \left(\frac{D}{D+2}\right) = \left(\frac{D+2}{D}\right) = \left(\frac{2}{D}\right) = (-1)^{\frac{D^2-1}{8}}$

Hence $\chi([2]) = 1$ if $D \equiv 1$ (mod $8$) and $\chi([2]) = -1$ if $D \equiv 5$ (mod $8$).

Case 2 $D \lt 0$

$\chi([2]) = \chi([-D + 2]) = \left(\frac{D}{-D+2}\right) = \left(\frac{-1}{-D+2}\right)\left(\frac{-D}{-D+2}\right) = \left(\frac{-D}{-D+2}\right) = \left(\frac{-D+2}{-D}\right) = \left(\frac{2}{-D}\right) =(-1)^{\frac{D^2-1}{8}}$

Hence $\chi([2]) = 1$ if $D \equiv 1$ (mod $8$) and $\chi([2]) = -1$ if $D \equiv 5$ (mod $8$).