Relatively prime identity? While working with rings, groups and other structures, I find the following
$ gcd(a,b) = 1 \iff ai + bj = 1$ for some $ i , j\in Z$
often arrises.  I feel like I encountered one side of this implication or the opposite many times especially when dealing with rings, PID, UFD and other such structures, but I am never allowed to assume this. Is there a proof for this statement or a counter example, I am not able to find any elegant proof that comes to mind immediately, neither a counter example.
 A: Let $R$ be a commutative ring with identity.  Let's say that two elements $a, b \in R$ have "GCD equal to $1$" if there is no irreducible element $p$ of $R$ that divides both $a$ and $b$.  You're asking when the following property holds: 
Property: If $a, b \in R$, then $\operatorname{GCD}(a,b) = 1$ if and only if the ideal generated by $a$ and $b$ is all of $R$.
The implication $\Leftarrow$ is obviously always true, since if $xa + yb = 1$ for some $x, y \in R$, then any irreducible element of $R$ which divides both $a$ and $b$ would have to divide $1$, which is impossible, because irreducible elements are by definition nonunits.
The converse is true for principal ideal domains, but false for general unique factorization domains.  If $k$ is a field, the ring $R = k[X,Y]$ is a UFD, the elements $X$ and $Y$ are relatively prime, but you cannot find polynomials $f, g \in R$ such that $X f(X,Y) + Y g(X,Y) = 1$.  
This is because the ideal $(X,Y)$ generated by $X$ and $Y$ is properly contained in $R$, being the kernel of the surjective ring homomorphism $R \rightarrow k, h(X,Y) \mapsto h(0,0)$.  So $\Rightarrow$ is false for the ring $k[X,Y]$.
Proof that the property holds for principal ideal domains:
Let $R$ be a PID, and let $a, b \in R$ be elements with GCD equal to one.  Let $J$ be the ideal generated by $a$ and $b$.  We want to show that $J = R$.  Since $R$ is a PID, we have $J = Rc$ for some $c \in R$.  If $c$ is a unit, we are done.  Otherwise, $c$ must be divisible by some irreducible element $p$.  The inclusions
$$(a), (b) \subset (c) \subset (p)$$
tell us that $p$ divides $a$ and $b$.  Therefore $a$ and $b$ are not relatively prime, contradiction.
A: You can prove a more general statement.
In order that there exist integers $i$ and $j$ satisfying the equation
$$
ai+bj = c,
$$
it is both necessary and sufficient that $\gcd(a,b)$ divides $c.$
Proof. Let $a = nd$ and $b = md.$ Then, if it is true that $ai+bj = c,$ we have
$$
ndi+mdj = d(ni+mj) = c.
$$
Thus, $d$ divides $c.$ The same argument works in the reverse direction.
Letting $c = 1,$ you recover your desired proof.
