<s>[INST] Differential equation with integration factor 2 please help me to solve this differential equation by integration factor :
$
(3y-xy+2)dx+xdy=0
$
I tried to solve this and got $x^2 -x$ as integration factor but when I affected that on main equation it still wasn't exact.(meaning I was wrong on calculation)
 [/INST] You have a non-exact differential equation, where it has the form of 
\begin{align*} M(x,y)dx + N(x,y)dy = 0 \tag{1} \end{align*} 
where $M(x,y) = 3y - xy +2$ and $N(x,y) = x$. Recall that you want to see if 
$\frac{M_y - N_x}{N}$ is a function of $x$ only or $\frac{N_x - M_y}{M}$ is a function of $y$ only. 
Calculating $\frac{M_y - N_x}{N}$, we have it equals $\frac{2-x}{x}$. The integrating factor is 
\begin{align*} e^{\int \frac{2-x}{x}dx} = x^2e^{-x} \end{align*}
From there you should have
\begin{align*} x^2(e^{-x})(3y-xy+2)dx + x^2(e^{-x})(x)dy = 0 \end{align*} 
is exact. Find the general solution to this exact equation and you have your answer.
------ Update -----------------------
Your solution comes out to 
\begin{align*} y(e^{-x}x^3) + 2e^{-x}(-2-2x-x^2) = 0 \end{align*}
After multiplying our integrating factor across our non-exact differential equations, we have 
\begin{align*} e^{-x}(3x^2y - x^3y + 2x^2)dx + e^{-x}x^3dy = 0 \end{align*}
We have that $\int e^{-x}x^3 dy = e^{-x}x^3y + g(x)$ (Remember that we partially integrated with respect to $y$ so we treated $x$ as a constant, so that you have a function of $g(x)$ that pops out).
If we differentiate this resulting equation with respect to $x$, we have that it becomes 
\begin{align*} 3x^2e^{-x}y - e^{-x}x^3y + g^{\prime}(x) \end{align*}
So we have that the exact equation we got implies that 
$3x^2e^{-x}y - e^{-x}x^3y + g^{\prime}(x) = e^{-x}(3x^2y - x^3y + 2x^2)$. So we integrate $e^{-x}(2x^2)$ with respect to $x$ and we get $2e^{-x}(-2-2x-x^2)$. 
Hopefully this helps.
</s>