Computing the intersection of two arithmetic sequences $(a\mathbb{Z} + b) \cap (c \mathbb{Z} + d)$ I am getting stuck writing a general formula for the intersection of two arithmetic sequences.  
$$ (a\mathbb{Z} + b) \cap (c \mathbb{Z} + d) = \begin{cases} 
\varnothing & \text{if ???} \\
?\mathbb{Z} + ? & \text{otherwise}\end{cases} $$
For any two arithmetic sequences, I would know how to compute their (possibly null) intersection, but I don't know how to write a formula in general.

It amounts to solving the system of simultaneous congruences:
$$\begin{cases}
x\equiv b\mod a\\x\equiv d\mod c
\end{cases}$$
This system has a solution idf and only if $b\equiv d\mod  \gcd(a,c)$, and it is unique modulo $\operatorname{lcm}(a,c)$.
