I have to show that every principal ideal domain is a unique factorisation domain.
I can show that every non invertible element that is not equal to $0$ can be written as product of irreducible elements.
However, I have troubles showing that if
$$p_1 \dots p_n = q_1 \dots q_m$$ where $q_i, p_i$ are irreducibles elements, then $n = m$ (I already showed that every $p_j = u_iq_i$ with $u_i$ invertible)
Any hints?
You know that in a PID a element is irreducible if and only if it is prime. Then, if $p_1$ on the left divides $q_1 \cdot \ldots \cdot q_m$ then it must divide one of this factors, lets say $q_i$. But $q_i$ is irreducible, thus
$$ p_1 = uq_i $$
where $u$ is invertible. By induction, you can then show that $m=n$
after $k$ times, if $m$ is less than $k$ (which happen only when $m<n$) $$ p_k \cdot \ldots \cdot p_n = u_k $$ Which is a contraddiction (the product of prime elements cannot be invertible). So $m \geq k$ and $$ p_k \cdot \ldots \cdot p_n = u_k q_k \cdots q_m $$ We can then apply the same argument I explained on top.
If otherwise m > n eventually you will have $$ 1 = u_n q_n \cdot \ldots \cdot q_m $$ which is a contraddiction, as shown before