<s>[INST] For any integer $p \ge 3$, the largest integer $r$ such that $(x-1)^r$ is a factor of the polynomial $2x^{p+1}-p(p+1)x^2+2(p^2-1)x-p(p-1)$ 
For any integer $p \ge 3$, the largest integer $r$ such that $(x-1)^r$ is a factor of the polynomial $2x^{p+1}-p(p+1)x^2+2(p^2-1)x-p(p-1)$

I have tried the following:
If $(x-1)^r$ is a factor of $2x^{p+1}-p(p+1)x^2+2(p^2-1)x-p(p-1)$ $\implies$
$(x-1)^r.f(x)=2x^{p+1}-p(p+1)x^2+2(p^2-1)x-p(p-1)$. Now $x-1$ is definitely a factor of $2x^{p+1}-p(p+1)x^2+2(p^2-1)x-p(p-1)$ as putting $x=1$ in the equation we  get $2-p(p+1)+2(p^2-1)-p(p-1)=0$. Now how do I draw a similar approach for $(x-1)^r$ . I was thinking of induction but I am stuck here. Can anyone help. The answer is 3 i.e $for \space r_{max}=3$ $(x-1)^r$ is a factor of the polynomial $2x^{p+1}-p(p+1)x^2+2(p^2-1)x-p(p-1)$
 [/INST] For $(x-1)^r$ to be a divisor of $f(x)$, we should have $f^{(r-1)}(1)=0$ (the $r-1$-st derivative).
So consider
$$f'(x)=2(p+1)x^{p}-2p(p+1)x+2(p^2-1).$$
Then $f'(1)=2(p+1)-2p(p+1)+2(p^2-1)=0.$ This means $(x-1)^2$ is a factor of $f$. 
Now consider,
$$f''(x)=2p(p+1)x^{p-1}-2p(p+1).$$
Thus $f''(1)=2p(p+1)-2p(p+1)=0$. This means $(x-1)^3$ is a factor of $f$. 
Now consider,
$$f'''(x)=2p(p-1)(p+1)x^{p-2}.$$
It is clear that $f'''(1) \neq 0$. Thus $(x-1)^3$ is the highest power of $(x-1)$ that divides $f(x)$.
</s>