Solve the ODE $y'=1-\frac{y}{x}$

Yes, the step before is enough to get a general solution. However, we can assume the constant to be an expression of other constants. The last step is just for simplification to the right-hand side.


$y' = 1 - \dfrac{y}{x}; \tag 1$

$y' + \dfrac{y}{x} = 1; \tag 2$

$xy' + y = x; \tag 3$

$(xy)' = y + xy'; \tag 4$

$(xy)' = x; \tag 5$

$xy = \dfrac{x^2}{2} + C, \; C \; \text{the arbitrary constant}; \tag 6$

$y = \dfrac{x}{2} + \dfrac{C}{x}; \tag 7$

We Check:

$y' = \dfrac{1}{2} - \dfrac{C}{x^2}; \tag 8$

$\dfrac{y}{x} = \dfrac{1}{2} + \dfrac{C}{x^2}; \tag 9$

$1 - \dfrac{y}{x} = \dfrac{1}{2} - \dfrac{C}{x^2} = y'! \; \checkmark \tag{10}$