I know that $\text{Ext}_{\mathbb{Z}}^1(\mathbb{Z}/(n), \mathbb{Z}) \cong \mathbb{Z}/(n)$.
I am trying to use this to show that the extensions of $\mathbb{Z}/(n)$ by $\mathbb{Z}$ are $$0 \to \mathbb{Z} \to W_a \to \mathbb{Z}/(n)\to 0$$ where $W_a = (\mathbb{Z} \oplus \mathbb{Z})/(-a,n)\cdot\mathbb{Z}$.
In a homework question I have it is now claimed that if $d = \gcd(a,n)$ then $W_a \cong \mathbb{Z}\oplus\mathbb{Z}/(d)$.
I have tried all sorts of "obvious" maps to get an isomorphism. One that I tried was taking $(z, k) \in \mathbb{Z}\oplus\mathbb{Z}/(d)$ to $(z,k) +((-a,n)\cdot\mathbb{Z})$, but this fails to even be well defined from what I can tell.
Does anyone have any hints/directions I could try to show that $W_a \cong \mathbb{Z}\oplus\mathbb{Z}/(d)$? It seems like this should pull out easily, but for some reason I have not been able to come up with an isomorphism.
Let $a' = \frac{a}{d}, n' = \frac{n}{d}.$ Then gcd$(a', n') = 1 \Rightarrow $ there exist $x, y \in \mathbb{Z}$ such that $a'x + n'y = 1.$ Note that $\{r = (-a', n'), s = (y, x) \}$ forms a $\mathbb{Z}$-basis of $\mathbb{Z} \oplus \mathbb{Z}$ (why?). Define a $\mathbb{Z}$-module homomorphism $\phi: \mathbb{Z}r \oplus \mathbb{Z}s \rightarrow (\mathbb{Z}/d\mathbb{Z}) \oplus \mathbb{Z}$ by $(\alpha r, \beta s) \mapsto (\alpha$ mod $d, \beta).$ Then $\phi$ is surjective and ker$\phi = (-a, n)\mathbb{Z}.$
${\bf Note:}$ This is just an intimidation of the proof of the structure theorem of finitely generated modules over a PID.