[proofplan]
To show $\chi_D$ is a Dirichlet character of modulus $D$, we check two properties: complete multiplicativity (holds by the multiplicativity of the Kronecker/Legendre-Jacobi symbol) and periodicity $\chi_D(p + D) = \chi_D(p)$ for all $p \in \mathbb{Z}$. Periodicity splits by congruence class of $d$ modulo $4$: for $d \equiv 1 \pmod 4$ (so $D = d$), the Legendre symbol $(d/p)$ depends only on $p \pmod{d}$ by quadratic reciprocity; for $d \equiv 3 \pmod 4$ (so $D = 4d$), the factor $(-1)^{(p-1)/2}$ depends only on $p \pmod 4$ and $(d/p)$ depends only on $p \pmod d$, so the product depends only on $p \pmod{4d}$; for $d \equiv 2 \pmod 4$ (so $D = 4d$), a similar argument combines $p \pmod 8$ and $p \pmod{|d|}$. In each case the period divides $D$.
[/proofplan]
[step:State the definition of $\chi_D$ in each residue-of-$d$ case and verify multiplicativity]
Recall $D = \operatorname{disc}(\mathcal{O}_L)$ for $L = \mathbb{Q}(\sqrt{d})$:
\begin{align*}
D &= \begin{cases} d & \text{if } d \equiv 1 \pmod 4, \\ 4d & \text{if } d \equiv 2, 3 \pmod 4. \end{cases}
\end{align*}
The function $\chi_D : \mathbb{Z} \to \{-1, 0, 1\}$ is defined by the Kronecker symbol extension of the Legendre/Jacobi symbol:
\begin{align*}
\chi_D(p) &= \begin{cases} 0 & \text{if } \gcd(p, D) > 1, \\ \bigl(\frac{D}{p}\bigr) & \text{otherwise}, \end{cases}
\end{align*}
where $\bigl(\frac{D}{p}\bigr)$ is the Jacobi symbol extended multiplicatively in $p$. Multiplicativity of $\chi_D$ as a function on $\mathbb{Z}$ follows from the multiplicativity of the Jacobi/Kronecker symbol in its "numerator" (when viewed with $D$ fixed and $p$ varying multiplicatively): for $p_1, p_2$ coprime to $D$,
\begin{align*}
\chi_D(p_1 p_2) &= \Bigl(\frac{D}{p_1 p_2}\Bigr) = \Bigl(\frac{D}{p_1}\Bigr) \Bigl(\frac{D}{p_2}\Bigr) = \chi_D(p_1) \chi_D(p_2).
\end{align*}
If $\gcd(p_1, D) > 1$ or $\gcd(p_2, D) > 1$, then $\gcd(p_1 p_2, D) > 1$, and both sides are $0$.
It therefore remains to verify **periodicity**: that $\chi_D(p + D) = \chi_D(p)$ for every $p \in \mathbb{Z}$. We treat the three cases.
[guided]
**Structure of $\chi_D$.** The function $\chi_D$ is defined to make $L(\chi_D, s)$ the "quadratic part" of the Dedekind zeta function $\zeta_L(s)$ of $L = \mathbb{Q}(\sqrt{d})$, through the identity $\zeta_L(s) = \zeta(s) L(\chi_D, s)$. Its values encode the splitting behaviour of rational primes in $\mathcal{O}_L$: $\chi_D(p) = 1$ if $p$ splits, $-1$ if $p$ is inert, $0$ if $p$ ramifies. Explicitly, for odd primes $p \nmid D$:
\begin{align*}
\chi_D(p) &= \Bigl(\frac{D}{p}\Bigr)_{\text{Legendre}},
\end{align*}
the Legendre symbol, and for composite $p$ it is extended multiplicatively via the Jacobi symbol. For $p \mid D$ (ramification), $\chi_D(p) = 0$.
**What we need for Dirichlet characters.** A Dirichlet character modulo $D$ is a multiplicative function $\chi : \mathbb{Z} \to \mathbb{C}$ that vanishes on integers sharing a factor with $D$, is non-zero on integers coprime to $D$, and is periodic with period $D$. Multiplicativity is built into the definition of Jacobi/Kronecker symbols; the vanishing at $\gcd(p, D) > 1$ is part of the definition; we only need to check periodicity.
**Multiplicativity in detail.** The Jacobi symbol $\bigl(\frac{D}{p}\bigr)$ is defined for $p > 0$ odd by factorising $p = q_1^{a_1} \cdots q_r^{a_r}$ and setting $\bigl(\frac{D}{p}\bigr) = \prod_i \bigl(\frac{D}{q_i}\bigr)^{a_i}$ in terms of Legendre symbols. The Kronecker symbol extends this to all integers by multiplicative continuation; both are completely multiplicative in their numerator variable. Hence $\chi_D(p_1 p_2) = \chi_D(p_1) \chi_D(p_2)$ whenever both sides are defined via the symbol, and zero otherwise.
**Plan for periodicity.** We split on the residue of $d$ modulo $4$, because the modulus $D$ differs by a factor of $4$ between $d \equiv 1$ and $d \not\equiv 1 \pmod 4$. In each case, we use quadratic reciprocity or the supplementary laws for $(2/p)$ to reduce $\chi_D(p)$ to a product of factors, each of which is periodic in $p$ with period dividing $D$.
[/guided]
[/step]
[step:Case $d \equiv 1 \pmod 4$: period divides $D = d$]
In this case $D = d$ and for odd $p$ with $p \nmid d$:
\begin{align*}
\chi_D(p) &= \Bigl(\frac{d}{p}\Bigr).
\end{align*}
For $p = 2$: if $2 \mid d$, $d$ would be even, contradicting $d \equiv 1 \pmod 4$, so $\gcd(2, d) = 1$; $\chi_D(2) = \bigl(\frac{d}{2}\bigr) \in \{\pm 1\}$ depending on the residue of $d$ modulo $8$ (via the Kronecker symbol).
For any $a \in \mathbb{Z}$, we compute $\chi_D(p + da) = \chi_D(p)$ as follows. Since $d$ is odd (as $d \equiv 1 \pmod 4$ forces $d$ odd), quadratic reciprocity gives (for $p, q$ odd coprime)
\begin{align*}
\Bigl(\frac{d}{p+da}\Bigr) &= \Bigl(\frac{d}{p}\Bigr).
\end{align*}
This is because the Jacobi symbol $\bigl(\frac{d}{\cdot}\bigr)$ depends only on $p \bmod d$ when $d \equiv 1 \pmod 4$, and $p + da \equiv p \pmod d$. More precisely: by the quadratic reciprocity law, for $d \equiv 1 \pmod 4$ (so $d$ is positive or we use Kronecker-symbol conventions for negative $d$, still giving period $d$),
\begin{align*}
\Bigl(\frac{d}{p}\Bigr) = \Bigl(\frac{p}{|d|}\Bigr) \cdot (\text{sign correction depending on sign of } d).
\end{align*}
The right-hand side is a Jacobi symbol $\bigl(\frac{p}{|d|}\bigr)$ in the denominator $|d|$, hence depends only on $p \bmod |d|$. Since $p + da \equiv p \pmod{|d|}$:
\begin{align*}
\chi_D(p + da) &= \chi_D(p).
\end{align*}
This establishes periodicity with period dividing $D = d$ for $d \equiv 1 \pmod 4$.
[guided]
**Quadratic reciprocity for $d \equiv 1 \pmod 4$.** For distinct odd primes $p, q$:
\begin{align*}
\Bigl(\frac{p}{q}\Bigr) \Bigl(\frac{q}{p}\Bigr) &= (-1)^{\frac{p-1}{2} \cdot \frac{q-1}{2}}.
\end{align*}
When one of $p, q$ is $\equiv 1 \pmod 4$, the product on the right is $(-1)^{0 \cdot \text{anything}} = 1$, so $\bigl(\frac{p}{q}\bigr) = \bigl(\frac{q}{p}\bigr)$. This extends multiplicatively to Jacobi symbols.
**Flipping the symbol.** For $d \equiv 1 \pmod 4$ odd and positive, and $p$ an odd positive integer coprime to $d$:
\begin{align*}
\Bigl(\frac{d}{p}\Bigr) &= \Bigl(\frac{p}{d}\Bigr),
\end{align*}
which depends on $p \bmod d$ only. The Jacobi symbol $\bigl(\frac{p}{d}\bigr)$ is defined by $p \bmod q$ factor-by-factor for each prime divisor $q \mid d$, and collapses to a single residue mod $d$ by CRT.
For negative $d \equiv 1 \pmod 4$ (so $d = -|d|$ with $|d| \equiv 3 \pmod 4$), the Kronecker symbol conventions add a sign depending on $p \bmod 4$, but the modulus of periodicity remains $|d|$. For our purposes the period divides $D = d$ (or $|d|$ in absolute value terms); multiplying $p$ by $1 + D\mathbb{Z}$ does not change $\chi_D(p)$.
**Adding a multiple of $D = d$.** The map $p \mapsto p + da$ preserves the residue class of $p$ modulo $d$ (and modulo $|d|$ for $d < 0$). Hence $\chi_D(p + da) = \chi_D(p)$.
**Extension to $p = 2$.** The Kronecker symbol at $p = 2$ is periodic in the "numerator" $D$ modulo $8$; for $d \equiv 1 \pmod 8$, $\chi_d(2) = 1$; for $d \equiv 5 \pmod 8$, $\chi_d(2) = -1$. This too depends only on $p \bmod D$, so periodicity extends to all integers.
[/guided]
[/step]
[step:Case $d \equiv 3 \pmod 4$: period divides $D = 4d$]
In this case $D = 4d$. For odd $p$ with $\gcd(p, D) = 1$ (i.e., $p$ odd, $p \nmid d$):
\begin{align*}
\chi_D(p) &= \Bigl(\frac{d}{p}\Bigr) \cdot (-1)^{\frac{p-1}{2}}.
\end{align*}
This formula comes from the supplementary factor in quadratic reciprocity when $d$ is $\equiv 3 \pmod 4$ (equivalently $d$ odd but not $\equiv 1 \pmod 4$), where the reciprocity law is
\begin{align*}
\Bigl(\frac{p}{d}\Bigr) &= \Bigl(\frac{d}{p}\Bigr) \cdot (-1)^{\frac{p-1}{2} \cdot \frac{|d|-1}{2}}.
\end{align*}
For $d \equiv 3 \pmod 4$, $\frac{|d|-1}{2}$ is odd, so the supplementary factor is $(-1)^{(p-1)/2}$.
We verify $\chi_D(p + 4da) = \chi_D(p)$ for any $a \in \mathbb{Z}$ and any $p$ coprime to $D = 4d$.
*Factor $\bigl(\frac{d}{p+4da}\bigr)$:* since $p + 4da \equiv p \pmod d$ (because $4a \in \mathbb{Z}$), the Jacobi symbol in the denominator $|d|$ depends only on the class mod $|d|$, giving
\begin{align*}
\Bigl(\frac{d}{p + 4da}\Bigr) &= \Bigl(\frac{d}{p}\Bigr).
\end{align*}
*Factor $(-1)^{((p + 4da) - 1)/2}$:* expanding the exponent,
\begin{align*}
\frac{(p + 4da) - 1}{2} &= \frac{p - 1}{2} + 2da.
\end{align*}
The addition of $2da$ is an integer, and $(-1)^{\text{integer}}$ only changes sign based on parity. Since $2da$ is even, $(-1)^{2da} = 1$:
\begin{align*}
(-1)^{((p + 4da) - 1)/2} &= (-1)^{(p-1)/2} \cdot (-1)^{2da} = (-1)^{(p-1)/2}.
\end{align*}
Multiplying the two factors together:
\begin{align*}
\chi_D(p + 4da) &= \Bigl(\frac{d}{p + 4da}\Bigr) \cdot (-1)^{((p + 4da) - 1)/2} = \Bigl(\frac{d}{p}\Bigr) \cdot (-1)^{(p-1)/2} = \chi_D(p).
\end{align*}
Finally, for $p = 2$: $\gcd(2, D) = \gcd(2, 4d) = 2 > 1$, so $\chi_D(2) = 0$, and for any even $p'$ of the form $p' = p + 4da$ with $p = 2$, we have $\gcd(p', D) \geq 2 > 1$, so $\chi_D(p') = 0 = \chi_D(2)$.
Therefore $\chi_D(p + D) = \chi_D(p)$ for every $p \in \mathbb{Z}$.
[guided]
**Why a factor of $4$ enters for $d \equiv 3 \pmod 4$.** The quadratic reciprocity law has a sign factor $(-1)^{\frac{p-1}{2} \cdot \frac{|d|-1}{2}}$ that depends on $p \bmod 4$ when $|d| \equiv 3 \pmod 4$. This sign is periodic with period $4$ in $p$, while the "main" Jacobi symbol $\bigl(\frac{p}{d}\bigr)$ is periodic with period $|d|$. The least common multiple is $4|d|$, matching $D = 4d$.
**Breaking $\chi_D$ into two factors.**
\begin{align*}
\chi_D(p) = \underbrace{\Bigl(\frac{d}{p}\Bigr)}_{\text{period } |d|} \cdot \underbrace{(-1)^{(p-1)/2}}_{\text{period } 4}.
\end{align*}
**Checking periodicity of each factor separately.**
*First factor.* $\bigl(\frac{d}{p + 4da}\bigr) = \bigl(\frac{d}{p}\bigr)$ because $p + 4da \equiv p \pmod d$ (and the Jacobi symbol in the bottom-variable $p$ is periodic with period $|d|$). Note $|4da|$ is a multiple of $|d|$, so adding $4da$ does not change the class mod $d$.
*Second factor.* Computing the exponent $\frac{(p + 4da) - 1}{2}$:
\begin{align*}
\frac{p + 4da - 1}{2} = \frac{p - 1}{2} + 2da.
\end{align*}
Since $2da$ is an integer (in fact, an even integer), $(-1)^{\text{even}} = 1$. So
\begin{align*}
(-1)^{(p + 4da - 1)/2} = (-1)^{(p-1)/2} \cdot (-1)^{2da} = (-1)^{(p-1)/2}.
\end{align*}
**Combining.** Both factors are invariant under $p \mapsto p + 4da = p + Da$, so $\chi_D(p + Da) = \chi_D(p)$, and periodicity with period dividing $D = 4d$ holds.
**Even $p$.** For $p$ even, $\gcd(p, D) = \gcd(p, 4d) \geq 2 > 1$ (since $4 \mid D$ and $2 \mid p$), so $\chi_D(p) = 0$. Similarly $\chi_D(p + D)$ for even $p$: $p + D$ is also even, so $\chi_D(p + D) = 0$. Periodicity on even integers reduces to $0 = 0$.
[/guided]
[/step]
[step:Case $d \equiv 2 \pmod 4$: period divides $D = 4d$]
Write $d = 2e$ with $e$ odd (since $d$ is square-free and even, $d = 2e$ with $\gcd(2, e) = 1$, and $e$ is square-free). Then $D = 4d = 8e$.
For odd $p$ with $\gcd(p, D) = 1$ (so $p$ is odd and $p \nmid e$, the latter because $p \nmid d$ implies $p \nmid e$):
\begin{align*}
\chi_D(p) &= \Bigl(\frac{2}{p}\Bigr) \cdot \Bigl(\frac{e}{p}\Bigr) \cdot \text{(supplementary sign)},
\end{align*}
where the supplementary sign is $(-1)^{(p^2 - 1)/8} \cdot (-1)^{((p-1)/2) \cdot ((|e|-1)/2)}$, depending on the sign and residue of $e$. For simplicity, the key facts we use are:
- $(2/p)$ depends only on $p \pmod 8$, by the second supplementary law: $\bigl(\frac{2}{p}\bigr) = (-1)^{(p^2 - 1)/8}$.
- $(e/p)$ depends only on $p \pmod{|e|}$ by quadratic reciprocity and periodicity of Jacobi symbols.
- The supplementary sign $(-1)^{((p-1)/2) \cdot ((|e|-1)/2)}$ depends only on $p \pmod 4$ (when $|e|$ is odd, which it is).
Let $f(p) = \chi_D(p)$. We must show $f(p + 8e) = f(p)$ for odd $p$ coprime to $D$.
*Factor $(2/p)$:* by the supplementary law, this depends only on $p \pmod 8$. Since $8e$ is a multiple of $8$, $p + 8e \equiv p \pmod 8$, and $\bigl(\frac{2}{p + 8e}\bigr) = \bigl(\frac{2}{p}\bigr)$.
*Factor $(e/p)$:* this depends only on $p \pmod{|e|}$. Since $8e \equiv 0 \pmod{|e|}$:
\begin{align*}
\Bigl(\frac{e}{p + 8e}\Bigr) &= \Bigl(\frac{e}{p}\Bigr).
\end{align*}
*Supplementary sign $(-1)^{((p-1)/2) \cdot ((|e|-1)/2)}$:* depends only on $p \pmod 4$. Since $8e \equiv 0 \pmod 4$, this is preserved.
Multiplying: $\chi_D(p + 8e) = \chi_D(p)$ for odd $p$ coprime to $D$.
For $p$ even: $\gcd(p, D) \geq 2$, so $\chi_D(p) = 0$; similarly $\chi_D(p + D) = 0$ (the sum of two even integers is even, so $\gcd(p + D, D) \geq 2$). Periodicity reduces to $0 = 0$.
Therefore in all three cases $\chi_D(p + D) = \chi_D(p)$ for every $p \in \mathbb{Z}$.
[guided]
**Writing $d = 2e$.** Since $d$ is square-free and $d \equiv 2 \pmod 4$, $d$ is even but not divisible by $4$: $d = 2e$ with $e$ odd. Moreover $e$ is square-free because $d$ is.
**The modulus $D = 4d = 8e$.** This is a multiple of $8$ (from $4d$) and a multiple of $|e|$ (from $8e$), and in fact $\operatorname{lcm}(8, |e|) = 8|e|$ when $\gcd(8, |e|) = 1$ (which holds since $e$ is odd).
**Kronecker symbol decomposition.** The Kronecker symbol $\bigl(\frac{D}{p}\bigr) = \bigl(\frac{4d}{p}\bigr)$ for odd $p$ decomposes multiplicatively:
\begin{align*}
\Bigl(\frac{4d}{p}\Bigr) = \Bigl(\frac{4}{p}\Bigr) \Bigl(\frac{d}{p}\Bigr) = \Bigl(\frac{2}{p}\Bigr)^2 \Bigl(\frac{2e}{p}\Bigr) = 1 \cdot \Bigl(\frac{2}{p}\Bigr) \Bigl(\frac{e}{p}\Bigr) = \Bigl(\frac{2}{p}\Bigr) \Bigl(\frac{e}{p}\Bigr),
\end{align*}
using $\bigl(\frac{4}{p}\bigr) = \bigl(\frac{2}{p}\bigr)^2 = 1$ for odd $p$.
**Periodicity of each factor.**
- $\bigl(\frac{2}{p}\bigr) = (-1)^{(p^2-1)/8}$: periodic with period $8$ (the second supplementary law).
- $\bigl(\frac{e}{p}\bigr)$: by quadratic reciprocity, related to $\bigl(\frac{p}{|e|}\bigr)$ up to sign factors depending on $p \bmod 4$; both components combine to a function of $p \bmod 4|e|$.
**Full periodicity.** The $\operatorname{lcm}$ of the periods $8$ (for the $\bigl(\frac{2}{p}\bigr)$ factor) and $4|e|$ (for the $\bigl(\frac{e}{p}\bigr)$ factor with its reciprocity sign) is $\operatorname{lcm}(8, 4|e|) = 8|e| = |D|$. So $\chi_D$ has period dividing $D$.
**Checking $\chi_D(p + D) = \chi_D(p)$ for odd $p$ coprime to $D$.** As above: each factor in the decomposition is preserved under the shift $p \to p + D$, so their product is preserved.
**For even $p$.** $\gcd(p, D) \geq 2$, so $\chi_D(p) = 0$. Similarly for $p + D$: $p + D$ is even (since both $p$ and $D$ are even), so $\gcd(p + D, D) \geq 2$. Periodicity holds.
[/guided]
[/step]