# If every irreducible element in $D$ is prime, then $D$ has the unique factorization property.

Suppose every irreducible element in a domain $D$ is prime.

I'm trying to prove this implication:

In a integral domain $D$, if $a=c_1c_2...c_n$ and $a=d_1d_2...d_m$ ($c_i,d_i$ irreducible), then $n=m$ and up to order $c_i$ and $d_i$ are associates for every $i$.

My Solution

For each $i$, $c_i$ divides $d_1...d_m$, since $c_i$ is irreducible, hence prime, $c_i$ has to divide some $d_j$, $j\le m$, but $c_i$ and $d_i$ are irreducible, so $c_i$ and $d_j$ are associate.

Is my solution is correct so far?

how can I prove $n=m$?

You've jumped right into deducing things without having a clear strategy, I think :) That's fine, you will need these thoughts shortly anyway. You could go about this a couple ways. You could strive to prove the statement directly by induction as vadim123 has recommended, or you could try an argument by contradiction by supposing $n<m$. With either of these setups, you would use your step above and vadim's cancellation suggestion to proceed. –  rschwieb May 30 '13 at 13:10
More precisely: prove your claim by induction on $\min(m,n)$.