TITLE: Sum of the divisor function over integers with restricted prime factors
QUESTION [6 upvotes]: Let $a,q$ be co-prime integers and let $P(a,q)$ denote the set of primes congruent to $a$ modulo $q$. Is it known whether one can give an asymptotic formula for the expression
$$\displaystyle \sum_{\substack{n \leq x \\ p | n \Rightarrow p \in P(a,q)}} d(n),$$
where $d(n)$ is the number of divisors of $n$?

REPLY [11 votes]: Sure.  The generating function for the sum you want is the Dirichlet series 
$$ 
\sum_{\substack{ n=1\\p|n \implies p\equiv a\pmod q}}^{\infty} \frac{d(n)}{n^s} = \prod_{p\equiv a\pmod q} \Big(1- \frac{1}{p^s}\Big)^{-2}.
$$ 
Using Dirichlet characters to isolate primes in progressions, you can express this as 
$$ 
\zeta(s)^{2/\phi(q)} \prod_{\chi \neq \chi_0 \pmod q} L(s,\chi)^{\overline{\chi(a)}/\phi(q)} G(s), 
$$ 
for a suitable Euler product $G$ converging absolutely to the right of $1/2$.  Now use the Selberg-Delange method (see e.g. Tenenbaum's book).  The asymptotic will be of the type 
$$ 
\sim C x(\log x)^{-1+2/\phi(q)}
$$ 
for a suitable constant $C$.