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?