find m and n of x^5+2x^2+mx+n if (x+1)^2 is factor comparing coeffcient like terms

just do a little long division. You get a remainder of (m+1)x + (n+2)

Since that must be zero,
m = -1, n = -2

check: x^5 + 2x^2 - x - 2 = (x+1)^2 (x-1) (x^2 - x + 2)