Let $R$ be an integral domain. Assume $R$ is UFD, show $R$ is GCD.
I did not find proof anywhere except one in proofwiki, but unfortunately there is a crucial part which I do not understand. https://proofwiki.org/wiki/UFD_is_GCD_Domain
Proof: Let $x,y\in R\setminus \{0\}$. As $R$ is UFD, we can write $x=ux_1x_2...x_r$, $y=vy_1y_2...y_s$, $u,v,x_i,y_j\in R$.
If $\exists x_i\in\{x_1,...,x_r\},y_j\in\{y_1,...,y_s\}$ such that $x_i$ and $y_j$ are associate., then rearrange $\{x_1,...,x_r\}$,$\{y_1,...,y_s\}$ such that $x=u(x_1...x_t)x_{t+1}...x_r, y=v(y_1...y_t)y_{t+1}...y_{s}$ where $1\leq t\leq min(r,s)$ and $x_i,y_i$ are associate for all $i\leq t$ and $\not\exists i \in[t+1,r],j\in[t+1,s]$ such that $x_i,y_j$ are associate.
Let $d:=x_1...,x_t$ if such $t$ exists otherwise let $d:=1$.
Claim: $d$ is a greatest common divisor of $x$ and $y$. Certainly, $d|x$ and $d|y$. Let $f\in R\setminus \{0\}$ such that $f|x$ and $f|y$(i.e. $\exists w,z\in R\setminus\{0\}$ such that $x=fw,y=fz$). We need to show $f|d$.
We assume $f$ is not a unit otherwise $f|d$ and we are done. Hence assume $f$ is not a unit and assume for contradiction that $f$ does not divide d.
Then the author claims $f$ must contain in its prime factorisation a irreducible element which does not divide $d$.
Why should this be true? For example $\mathbb{Z}$ is a UFD and 4 does not divide 6 but all irreducible factors of 4, namely 2,-2, divide 6.