You should remember that a root of polynomial of `n-th ` order of multiplicity, cancels all the `(n-1)-th` derivative of polynomial.

Reasoning by analogy yields that if `f(x)` is divided by g(x), hence, the roots of `g(x)` are the roots of`f(x), ` moreover, if the roots of `g(x)` are roots of multiplicity 2, hence, they cancel `f(x)` and `f'(x).`

Notice that the equation of polynomial `g(x)` is the expansion of binomial `(x-1)^2` .

Solving the equation `g(x) = 0` yields that `x_1=x_2 = 1` , hence, the root `x=1` is a root of multiplicity 2, thus, `f(1) = 0` and `f'(1) = 0` .

You need to evaluate f(1) such that:

`f(1) = 1^n + 1^2 - (n+2)*1 + n`

`f(1) = 1 + 1 - n - 2 + n = 0`

Hence, `x=1 ` verifies the equation `f(1) = 0.`

You need to check if `x=1` verifies `f'(1)=0` , hence, you need to find first f'(x) such that:

`f'(x) = n*x^(n-1) + 2x - n - 2`

Substituting 1 for x yields:

`f'(1) = n*1^(n-1) + 2*1 - n - 2 => f'(1) = n + 2 - n - 2 = 0`

Notice that `x = 1` checks `f'(1) = 0.`

**Hence, since the root of polynomial `g(x) = (x-1)^2,x = 1` , of multiplicity `2` , verifies `f(1)` and `f'(1), ` thus, the polynomial `f(x)` is completely divided by `g(x).` **