Unique factorization of an element in an UFD By definition:

An integral domain $R$ is a unique factorization domain if the following conditions are satisfied:
  
  
*
  
*Every element $a \in R$, $a \neq 0$ that is not a unit can be factored into a product $a = c_1 \cdots c_n$ where $c_1,\dots,c_n \in R$ are irreducible elements.
  
*If $c_1,\dots,c_n$ and $d_1,\dots,d_m$ are two factorizations of the same element of $R$ into irreducibles, then $n = m$ and $d_j$ can be renumbered so that $c_i$ and $d_i$ are associates.
  

I need to prove that every element $a \in R$, $a \neq 0$ which is not a unit can be written uniquely as:
\begin{equation}
 a = up_1^{e_1} \cdots p_s^{e_s}
\end{equation}
where $u \in R$ is a unit, $p_1,\dots,p_s \in R$ are irreducible elements mutually not associate and $e_1,\dots,e_s \in \mathbb{N} \setminus \{0\}$. I think I need to start with an arbitrary factorization $a = c_1 \cdots c_n$, then use the following result, but honestly I don't know how to put it formally.

Let $R$ be an integral domain and let $a,b \in R$. If $a$ and $b$ are associate elements, then $a,b \neq 0$ and $a = b \cdot u$ for some unit $u \in R$.


By definition of unique factorization domain, the given element $a$ has a factorization in irreducibles $a = c_1 \cdots c_n$. We proceed by induction on the length of the factorization ($n \in \mathbb{N}$, $n \geq 1$). The base of induction ($n = 1$) is trivial. In fact, if $a = c_1$ is a factorization of $a$ in irreducibles, then $a = up_1^{e_1}$ where $u := 1$, $p_1 := c_1$ and $e_1 := 1$.
In the induction step, we assume $n \geq 2$ and we suppose that every nonzero non-unit element with a factorization of lenght $n-1$ can be written uniquely in the desired form. Let $b := c_1 \cdots c_{n-1}$. Then $b = c_1 \cdots c_{n-1}$ is a factorization of $b$ in irreducibles and by inductive hyphotesis we have that $b = vp_1^{d_1} \cdots p_r^{d_r}$ for some unit $v \in R$, for some irreducible elements $p_1,\dots,p_r \in R$ which are mutually not associate and for some $d_1,\dots,d_r \in \mathbb{N} \setminus \{0\}$. Thus $a = vp_1^{d_1} \cdots p_r^{d_r}c_n$. Now we have two possibilities:


*

*$c_n \nsim p_i$ for all $1 \leq i \leq r$. In this case, let $u := v$, $s := r+1$, $p_s := c_n$, $e_i := d_i$ for all $1 \leq i \leq r$ and $e_s := 1$ so that $a = up_1^{e_1} \cdots p_s^{e_s}$ (remember that a unique factorization domain is a commutative ring by definition).

*$c_n \sim p_i$ for some $1 \leq i \leq r$. In this case, by applying the result mentioned in the question we get a unit $u_i \in R$ such that $c_n = p_iu_i$. Now let $u := vu_i$, $s := r$, $e_j := d_j$ for all $1 \leq j \leq s$ with $j \neq i$ and $e_i := d_i + 1$ so that $a = up_1^{e_1} \cdots p_s^{e_s}$ (again, $R$ is a commutative ring).

