Answer
$y = (x~ln~x+Cx)^{-1}$
Work Step by Step
$xy'+y = -xy^2$
$y'+\frac{1}{x}y = -y^2$
Note that $n=2$
Let $u = y^{1-n} = y^{-1}$
A first-order linear differential equation is one that can be put into the form:
$\frac{dy}{dx} + P(x)~y = Q(x)$
We can consider the given equation with $u$:
$y'+\frac{1}{x}y = -y^2$
$\frac{du}{dx} +(-1)\frac{1}{x}u = (-1)(-1)$
$\frac{du}{dx} -\frac{1}{x}u = 1$
Let $P(x) = \frac{-1}{x}$
Let $Q(x) = 1$
We can find the integrating factor:
$I(x) = e^{\int \frac{-1}{x}~dx} = e^{-1~ln~x} = e^{ln~x^{-1}} = \frac{1}{x}$
We can multiply by the integrating factor:
$\frac{1}{x}~\frac{du}{dx}+(\frac{-1}{x^2})~u = \frac{1}{x}$
$\frac{d}{dx}(\frac{1}{x}~u) = \frac{1}{x}$
We can integrate both sides of the equation:
$\frac{1}{x}~u = \int \frac{1}{x}~dx$
$\frac{1}{x}~u = ln~x+C$
$u = x~ln~x+Cx$
We can use the substitution $u = y^{-1}$:
$y^{-1} = x~ln~x+Cx$
$y = (x~ln~x+Cx)^{-1}$