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:

1. 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.
2. 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: $$$$a = up_1^{e_1} \cdots p_s^{e_s}$$$$ 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$$.

The action you take is identical to the following situation where you consider words that are monomials in several variables: for example $$(\frac{3}{4}x)(5y)(x)(\frac{5}{3}x)(\frac{2}{5}z)(\frac{1}{4}y)$$ First group all associates: $$(\frac{3}{4}x)(x)(\frac{5}{3}x).(5y)(\frac{1}{4}y). (\frac{2}{5}z)$$ Then for each group of accociates extract a unique unit: $$(\frac{3}{4}\frac{5}{3})(x)(x)(x).(5\frac{1}{4})(y)(y).(\frac{2}{5})(z)$$ Then bring all units together and simplify them and exponentiate the rest: $$\frac{5}{8}x^3y^2z$$
• Follow the three steps in the example: First note that you can regroup the associates and relabel them with the same label but a different unit, like in $u_{1,1}p_1.u_{1,2}p_1.u_{1,3}p_1$ and $u_{2,1}p_2.u_{2,2}p_2.u_{2,3}p_2$ etc... Then show that in each group you can put the units in the front to form just one unit per group as in $u_{1,1}u_{1,2}u_{1,3}.p_1.p_1.p_1$ . Then show that all the units of each group can be put in front as one uniuqe unit followed by equal identical elements that can be exponentiated. Commented Aug 26, 2019 at 13:40
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).