Can we always write $gcd(x,y)$ as $ax+by$ in UFD? Let $R$ be a commutative ring with unity. Now assume that $R$ is Unique Factorization Domain, but not necessarily Principal Ideal Domain. 
Question: Let $x,y\in R$ be such that their GCD exists in $R$, and let $d=\gcd(x,y)$. Then does there always exists $a,b\in R$ such that $d=ax+by$?
The answer is yes if the ring is PID, but here I am not considering $R$ as a PID, but considering $x,y$ for which GCD exists. 

Here $R$ is a UFD, so every element has a factorization. For $x,y\in R$, we say that $d$ is GCD of $x,y$ (provided it exists), if 
(1) $d$ divides both $x,y$.
(2)If $c$ divides $x,y$ then $c$ divides $d$.
I think, common divisors of two elements in a UFD always exists (for example, at least $1$). But, GCD does not exists means we can find two divisors, which are maximal but different. 

The answer is NO. We consider the standard example $\mathbb{Z}[x]$, which is a UFD but not a PID. In fact, $(2,x)$ is not a principal ideal. Consider the elements $2$ and $x$ in this ring. The only divisors of $2$ are $1$ and $2$, and among them only $1$ divides $x$. This means $\gcd(2,x)=1$. Then can we write $1$ as $2a+bx$? Clearly, NO. Simply compare the constant coefficients on both sides. 
