Answer
$f(x)=e^{x^2/2}+1$
Work Step by Step
Let $y=f(x)$.
The differential equation would be $y'=xy-x$.
Find the general solution:
$\frac{dy}{dx}=xy-x$
$\frac{dy}{dx}=x(y-1)$ (Separate the variables)
$\frac{1}{y-1}dy=xdx$ (Integrate)
$\int \frac{1}{y-1}dy=\int x dx$
$\ln (y-1)=\frac{x^2}{2}+C$
Find the value of $C$ by substituting $y(0)=2$:
$\ln (2-1)=\frac{0^2}{2}+C$
$\ln 1=\frac{0}{2}+C$
$0=0+C$
$C=0$
So, $\ln (y-1)=\frac{x^2}{2}$
Taking the exponent,
$y-1=e^{x^2/2}$
$y=e^{x^2/2}+1$
Thus, the solution is $f(x)=e^{x^2/2}+1$.