Question: Consider the differential equation $M(x, y)dx + N(x,y)dy = 0$. Prove that there exists an integrating factor that is dependent on $x$ if and only if $\frac {1}{N}(M_y - N_x) = f(x)$, a function of $x$ only.
Proof: Here the given general first order differential equation is $$M(x, y)dx + N(x,y)dy = 0\tag1$$
We shall suppose that there exists an integrating factor that depends only on $~x~$: $~\mu=\mu(x)~$
Now if $~\mu~$ is an integrating factor, then $~M(x, y)\mu(x)dx + N(x,y)\mu(x)dy~$ must be exact. i.e., $$\dfrac{\partial}{\partial y}\left[M(x, y)\mu(x)\right]=\dfrac{\partial}{\partial x}\left[N(x, y)\mu(x)\right]$$ $$\implies\mu\dfrac{\partial M}{\partial y}=\dfrac{\partial\mu}{\partial x}N+\mu\dfrac{\partial N}{\partial x}$$ $$\implies \dfrac{\partial\mu}{\partial x}=\dfrac 1{N}\left(\dfrac{\partial M}{\partial y}-\dfrac{\partial N}{\partial x}\right)\mu\tag2$$ Now if $~\mu~$ depends only on $~x~$ and not on $~y~$, then necessarily $~\mu~$ depends only on $~x~.$ Thus the RHS of the above equation must be a function of $~x~$ only. i.e., $$\dfrac 1{N}\left(\dfrac{\partial M}{\partial y}-\dfrac{\partial N}{\partial x}\right)=f(x)$$ Thus the equation $(2)$ becomes., $$\dfrac{\partial\mu}{\partial x}-f(x)\mu=0$$ which is a first order linear differential equation and can be solved and the solution is $$\mu(x)=A \exp\left[\int f(x) dx\right]=A \exp\left[\int \dfrac 1{N}\left(\dfrac{\partial M}{\partial y}-\dfrac{\partial N}{\partial x}\right) dx\right]$$which gives us an integrating factor for the equation $(1)$ in the form $~\frac 1{N}\left(\frac{\partial M}{\partial y}-\frac{\partial N}{\partial x}\right)~$ depends on $~x~$ only.
Conversely, let for the equation $(1)$, $$\dfrac 1{N}\left(\dfrac{\partial M}{\partial y}-\dfrac{\partial N}{\partial x}\right)=f(x)\implies Nf(x)=\dfrac{\partial M}{\partial y}-\dfrac{\partial N}{\partial x}\tag3$$
Multiplying both side of $(1)$ by $~e^{\int f(x)dx}~$, we have $~M_1~dx+N_1~dy=0~$ where $~M_1=M~e^{\int f(x)dx}~$ and $~N_1=N~e^{\int f(x)dx}~.$
Now $$\dfrac{\partial M_1}{\partial y}=\dfrac{\partial M}{\partial y}e^{\int f(x)dx}\tag4~~~~~~~~~~\text{and}$$
$$\dfrac{\partial N_1}{\partial x}=\dfrac{\partial N}{\partial x}e^{\int f(x)dx}+N~e^{\int f(x)dx}~f(x)=e^{\int f(x)dx}\left\{\dfrac{\partial N}{\partial x}+Nf(x)\right\}$$ $$\implies \dfrac{\partial N_1}{\partial x}=e^{\int f(x)dx}\left\{\dfrac{\partial N}{\partial x}+\dfrac{\partial M}{\partial y}-\dfrac{\partial N}{\partial x}\right\}~,~~~\text{from $(3)$}$$
$$\implies \dfrac{\partial N_1}{\partial x}=e^{\int f(x)dx}~\dfrac{\partial M}{\partial y}\tag5$$ From equation $(4)$ and $(5)$, it is clear that $$\dfrac{\partial M_1}{\partial y}=\dfrac{\partial N_1}{\partial x}$$which shows that $~M_1~dx+N_1~dy=0~$ is an exact differential equation and hence $~e^{\int f(x)dx}~$ is it's integrating factor that depends only on $~x~$.