[proofplan]
We first prove the formula in the absolute convergence region $\operatorname{Re}(s)>1$ by comparing Euler products: the principal character deletes exactly the Euler factors corresponding to primes dividing $q$. The finite product over $p \mid q$ is entire, so multiplying the meromorphic continuation of $\zeta(s)$ gives the meromorphic continuation of $L(s,\chi_0)$ to $\operatorname{Re}(s)>0$. Finally, the pole and residue at $s=1$ are obtained by multiplying the simple pole of $\zeta(s)$ by the nonzero finite factor evaluated at $s=1$.
[/proofplan]
[step:Compare Euler products in the half-plane of absolute convergence]
Define the finite Euler factor
\begin{align*}
P_q: \mathbb{C} &\to \mathbb{C} \\
s &\mapsto \prod_{p \mid q}(1-p^{-s}),
\end{align*}
where the product is over the prime divisors of $q$, and where the empty product is $1$ when $q=1$.
For $\operatorname{Re}(s)>1$, the Dirichlet series defining $L(s,\chi_0)$ is absolutely convergent because $|\chi_0(n)| \leq 1$ for all $n \in \mathbb{N}$ and $\sum_{n=1}^{\infty} n^{-\operatorname{Re}(s)}$ converges. In this region, the Euler product for Dirichlet series attached to completely multiplicative characters gives
\begin{align*}
L(s,\chi_0)
=
\prod_p (1-\chi_0(p)p^{-s})^{-1}.
\end{align*}
For a prime $p$, one has $\chi_0(p)=0$ if $p \mid q$ and $\chi_0(p)=1$ if $p \nmid q$. Hence
\begin{align*}
L(s,\chi_0)
&=
\prod_{p \nmid q}(1-p^{-s})^{-1} \\
&=
\left(\prod_p (1-p^{-s})^{-1}\right)\prod_{p \mid q}(1-p^{-s}) \\
&=
\zeta(s)P_q(s).
\end{align*}
Here the last equality uses the Euler product for the Riemann zeta function in $\operatorname{Re}(s)>1$. These Euler product facts are being used as prerequisites not yet resolved to wiki theorem IDs: Euler product for Dirichlet $L$-functions and Euler product for $\zeta(s)$.
[guided]
The purpose of this step is to identify exactly how the principal character changes the Euler product for $\zeta(s)$. Define
\begin{align*}
P_q: \mathbb{C} &\to \mathbb{C} \\
s &\mapsto \prod_{p \mid q}(1-p^{-s}).
\end{align*}
This is a finite product over the prime divisors of $q$; if $q=1$, there are no such primes, and the product is defined to be $1$.
Let $s \in \mathbb{C}$ satisfy $\operatorname{Re}(s)>1$. Since $|\chi_0(n)| \leq 1$ for every $n \in \mathbb{N}$, we have
\begin{align*}
\sum_{n=1}^{\infty}\left|\frac{\chi_0(n)}{n^s}\right|
\leq
\sum_{n=1}^{\infty}\frac{1}{n^{\operatorname{Re}(s)}}<\infty.
\end{align*}
Thus the Dirichlet series defining $L(s,\chi_0)$ is absolutely convergent in this half-plane, so its Euler product is valid:
\begin{align*}
L(s,\chi_0)
=
\prod_p (1-\chi_0(p)p^{-s})^{-1}.
\end{align*}
The principal character satisfies $\chi_0(p)=0$ exactly for primes $p$ dividing $q$, and $\chi_0(p)=1$ for primes $p$ not dividing $q$. Therefore the Euler factor at a prime divisor of $q$ is
\begin{align*}
(1-\chi_0(p)p^{-s})^{-1}=(1-0)^{-1}=1,
\end{align*}
while the Euler factor at a prime not dividing $q$ is
\begin{align*}
(1-\chi_0(p)p^{-s})^{-1}=(1-p^{-s})^{-1}.
\end{align*}
Hence
\begin{align*}
L(s,\chi_0)
=
\prod_{p \nmid q}(1-p^{-s})^{-1}.
\end{align*}
The zeta Euler product in the same half-plane is
\begin{align*}
\zeta(s)=\prod_p (1-p^{-s})^{-1}.
\end{align*}
Multiplying this product by $\prod_{p \mid q}(1-p^{-s})$ cancels precisely the Euler factors with $p \mid q$, so
\begin{align*}
\zeta(s)\prod_{p \mid q}(1-p^{-s})
=
\prod_{p \nmid q}(1-p^{-s})^{-1}
=
L(s,\chi_0).
\end{align*}
The Euler product facts used here are prerequisites not yet resolved to wiki theorem IDs: Euler product for Dirichlet $L$-functions and Euler product for $\zeta(s)$.
[/guided]
[/step]
[step:Continue the identity meromorphically to $\operatorname{Re}(s)>0$]
For each prime $p \mid q$, the function
\begin{align*}
s \mapsto 1-p^{-s}=1-e^{-s\log p}
\end{align*}
is entire, so $P_q$ is entire as a finite product of entire functions. The Riemann zeta function has a meromorphic continuation to $\operatorname{Re}(s)>0$ with its only pole in this half-plane at $s=1$ (citing a result not yet in the wiki: meromorphic continuation of the Riemann zeta function). Therefore
\begin{align*}
s \mapsto \zeta(s)P_q(s)
\end{align*}
is meromorphic on $\operatorname{Re}(s)>0$, with possible pole only at $s=1$.
Since this [meromorphic function](/page/Meromorphic%20Function) agrees with $L(s,\chi_0)$ on the nonempty [open set](/page/Open%20Set) $\operatorname{Re}(s)>1$, it gives the meromorphic continuation of $L(s,\chi_0)$ to $\operatorname{Re}(s)>0$. Thus, for every $s$ with $\operatorname{Re}(s)>0$ and $s \neq 1$,
\begin{align*}
L(s,\chi_0)=\zeta(s)\prod_{p \mid q}(1-p^{-s}).
\end{align*}
[guided]
The identity has already been proved where the original Dirichlet series converges absolutely, namely in $\operatorname{Re}(s)>1$. To move it into the larger half-plane $\operatorname{Re}(s)>0$, we inspect the right-hand side.
For a fixed prime $p \mid q$, the map
\begin{align*}
\mathbb{C} &\to \mathbb{C} \\
s &\mapsto 1-p^{-s}
\end{align*}
is entire, because $p^{-s}=e^{-s\log p}$ and the exponential function is entire. Since there are only finitely many primes dividing $q$, the product
\begin{align*}
P_q(s)=\prod_{p \mid q}(1-p^{-s})
\end{align*}
is also entire.
Now use the meromorphic continuation of the Riemann zeta function to the half-plane $\operatorname{Re}(s)>0$, with only a pole at $s=1$ in that region. This prerequisite is not yet resolved to a wiki theorem ID. Multiplying the meromorphic function $\zeta(s)$ by the entire function $P_q(s)$ gives a meromorphic function
\begin{align*}
s \mapsto \zeta(s)P_q(s)
\end{align*}
on $\operatorname{Re}(s)>0$.
On the smaller open half-plane $\operatorname{Re}(s)>1$, the previous step proved
\begin{align*}
L(s,\chi_0)=\zeta(s)P_q(s).
\end{align*}
Therefore the meromorphic function $\zeta(s)P_q(s)$ is the continuation of the original Dirichlet series defining $L(s,\chi_0)$. Consequently, throughout the half-plane $\operatorname{Re}(s)>0$, away from the possible singular point $s=1$, one has
\begin{align*}
L(s,\chi_0)=\zeta(s)\prod_{p \mid q}(1-p^{-s}).
\end{align*}
[/guided]
[/step]
[step:Evaluate the residue at the inherited pole]
The Riemann zeta function has a simple pole at $s=1$ with residue $1$ (citing a result not yet in the wiki: simple pole of $\zeta(s)$ at $s=1$). Thus there is a function
\begin{align*}
h: \{s \in \mathbb{C}:\operatorname{Re}(s)>0\} &\to \mathbb{C}
\end{align*}
holomorphic near $s=1$ such that
\begin{align*}
\zeta(s)=\frac{1}{s-1}+h(s)
\end{align*}
near $s=1$. Since $P_q$ is holomorphic near $s=1$, we obtain
\begin{align*}
L(s,\chi_0)
=
\left(\frac{1}{s-1}+h(s)\right)P_q(s).
\end{align*}
The coefficient of $(s-1)^{-1}$ in this Laurent expansion is $P_q(1)$. Hence
\begin{align*}
\operatorname{Res}_{s=1}L(s,\chi_0)
=
P_q(1)
=
\prod_{p \mid q}(1-p^{-1}).
\end{align*}
Each factor $1-p^{-1}$ is nonzero, so the pole remains simple.
[guided]
The only possible singularity in the half-plane $\operatorname{Re}(s)>0$ comes from $\zeta(s)$ at $s=1$, because $P_q$ is entire. The zeta function has a simple pole at $s=1$ with residue $1$; this prerequisite is not yet resolved to a wiki theorem ID. Equivalently, there is a function
\begin{align*}
h: \{s \in \mathbb{C}:\operatorname{Re}(s)>0\} &\to \mathbb{C}
\end{align*}
holomorphic in a neighbourhood of $s=1$ such that
\begin{align*}
\zeta(s)=\frac{1}{s-1}+h(s)
\end{align*}
near $s=1$.
Multiplying by the finite Euler factor gives
\begin{align*}
L(s,\chi_0)
=
\zeta(s)P_q(s)
=
\left(\frac{1}{s-1}+h(s)\right)P_q(s).
\end{align*}
Since $P_q$ is holomorphic at $s=1$, the coefficient of $(s-1)^{-1}$ in this Laurent expansion is exactly $P_q(1)$. Therefore
\begin{align*}
\operatorname{Res}_{s=1}L(s,\chi_0)
=
P_q(1)
=
\prod_{p \mid q}(1-p^{-1}).
\end{align*}
No cancellation of the pole occurs, because for every prime $p \mid q$,
\begin{align*}
1-p^{-1}>0.
\end{align*}
Thus $P_q(1)\neq 0$, and the pole inherited from $\zeta(s)$ is still simple.
[/guided]
[/step]
[step:Identify the finite Euler factor with $\varphi(q)/q$]
Write the prime factorisation of $q$ as
\begin{align*}
q=\prod_{j=1}^{r} p_j^{a_j},
\end{align*}
where $r \in \mathbb{N}\cup\{0\}$, the $p_j$ are distinct primes, and $a_j \in \mathbb{N}$. The Euler totient product formula gives
\begin{align*}
\varphi(q)=q\prod_{j=1}^{r}\left(1-\frac{1}{p_j}\right)
\end{align*}
(citing a result not yet in the wiki: Euler product formula for Euler's totient function). Dividing by $q$ gives
\begin{align*}
\frac{\varphi(q)}{q}
=
\prod_{j=1}^{r}\left(1-\frac{1}{p_j}\right)
=
\prod_{p \mid q}(1-p^{-1}).
\end{align*}
Combining this with the residue computation proves
\begin{align*}
\operatorname{Res}_{s=1}L(s,\chi_0)
=
\prod_{p \mid q}(1-p^{-1})
=
\frac{\varphi(q)}{q}.
\end{align*}
This completes the proof.
[/step]