On proving every ideal of $\mathbb{Z}_n$ is principal

The existence of these $a_i$ is a slightly more general form of Bezout's identity. We are technically taking representatives $0\leq y_1,\ldots,y_k\leq n-1$ in $\mathbb{Z}$ for the $x_1,\ldots,x_k\in\mathbb{Z}_n$, letting $D=\gcd(y_1,\dots,y_k)$, using Bezout's identity for $\mathbb{Z}$ to show that there are $b_1,\ldots,b_k\in\mathbb{Z}$ such that $\sum_{i=1}^k b_iy_i=D$, then reducing mod $n$ to the equation $\sum_{i=1}^k a_ix_i=d$ where $a_i=b_i+n\mathbb{Z}$ and $d=D+n\mathbb{Z}$.


Presumably Ash has already proved that $\bf Z$ is a PID. Now $d$ is the gcd of the $x_i$ in $\bf Z$, which is a PID, so working in $\bf Z$ we have $\sum_ia_ix_i=d$ for some $a_i$.