Prove that any polynomial $f(x)\in K[X]$, where $K$ is a field, can be uniquely factored into a product of irreducible polynomials times a constant. Suppose that $K$ is a field. Show that every nonzero polynomial $f=f(x)\in K[X]$ can be factored in the form $f(x)=ap_1(x)p_2(x)\cdots p_n (x)$ where $a$ is a constant and $p_1(x), p_2(x),\ldots,p_n(x)$ are not necessarily distinct irreducible monic polynomials. Then prove its uniqueness.
This is a homework question from Galois Theory course. It is analogous to but different from the Fundamental Theorem of Algebra. Since the field $K$ does not have to contain all the roots of $f(x)$, it is not guaranteed $f(x)$ can be factored into a product linear monic polynomials. However, no matter if the field contains all its roots or not,  it can always be factored into a product of irreducible monic polynomials. 
For instance, $f(x)=x^4+2x^2+1\in \mathbb R[X]$, where $\mathbb R$ does not contain any roots of $f(x)$. However it can be factored as $f(x)=(x^2+1)(x^2+1)$ where $(x^2+1) $ is irreducible over $\mathbb R$.

My method is this.
Case 1: If $f(x)$ is irreducible, then factor out the leading coefficient and we are done.
Case 2: Suppose that $f(x)$ is not irreducible. Then $\exists g_1,q_1\in K[X]$ such that $f(x)=p_1(x)q_1(x)$ where $1\le\deg p_1\lt \deg f$ and $1\le\deg q_1\lt \deg f$.
If $p_1(x)$ and $q_1(x)$ are irreducible, then factor out the leading coefficients and we are done.
If they are not, we can do the same process to $p_1(x)$ and $q_1(x)$ and this process has to stop at some point because $\deg f=$ the sum of the degree of each irreducible polynomials on the right hand side of the equation and it is finite. 
Therefore the existence has been proven.

Can anyone check if this proof is valid and also help me with proving the uniqueness?
 A: Well, it's more clean to phrase it as a proof by induction, but your idea is essentially right. For proving uniqueness, note that $K[X]$ is Euclidean, since $K$ is a field. This implies that irreducibility is equivalent to something that helps marvelously.
A: Your proof regarding existence looks good. It can however be clearer using induction on the degree of a polynomial.
Regarding uniqueness, let’s use induction.
1) Uniqueness is clear for a polynomial of degree equal to $0$.
2) Suppose that uniqueness is proven for all polynomials with degree less or equal to $n$ and consider a polynomial $P$ with degree equal to $n+1$.
Without loss of generality, we can suppose that $P$ is a monic polynomial. Suppose moreover that
$$P=R_1 \dots R_k=S_1 \dots S_l$$ where $R_1, \dots, R_k,S_1, \dots, S_l$ are all monic  irreducible. Then by Euclid’s lemma, $R_1$ divides one of $S_1, \dots, S_l$. And therefore is equal to one of those as they are supposed to be irreducible. By reordering, we can suppose that $R_1 =S_1$. But then $P/R_1$ is of degree less than $n+1$ and by induction hypothesis is having a unique factorization in irreducible polynomials. This is then also the case of $P=R_1(P/R_1)$.
