The factor theorem states that for P being a polynomial of degree n, then it can be wrote as a factor of its root and another polynomial
Therefore being P(x) = a0 + a1x + a2x^2 ... + anx^n with no more than n roots, its also true that
P(x) = (x-r)R(x), for P(r) = 0
Proof.
Let P/Q = G + R/Q, which is just a normal polynomial division with G being the integer polynomial and R/Q having no in common factor such that deg R < deg Q.
Its true that P = qG + R. For a special case, lets assume q = (x-r) for r being a root of P
Then we get: P = (x-r)G + R
Since deg Q > deg R its correct that deg R = 0 or R = 0, so R is a constant.
Now for the input r we get P(r) = (r - r)G(x) + P(r). Therefore its true that P(x) = (x-r)G(x).
This theorem can be extensed into factoring the whole polynomials in respect to its root, just follow this process with G(x) and so on