Close. You forget to include constant of integration:
$$f(x)=g(x)+a_0+a_1x+a_2x^2+\dots+a_{n-1}x^{n-1}$$
For arbitrary constants $a_k$.
For example:
$$f(x)=g(x)+a_0+a_1x+a_2x^2\tag1$$
$$f'(x)=g'(x)+\require{cancel}\cancelto0{\frac{da_0}{dx}}+\cancelto{a_1}{\frac{da_1x}{dx}}+\cancelto{2a_2x}{\frac{da_2x^2}{dx}}\\f'(x)=g'(x)+a_1+2a_2x$$
$$f''(x)=g''(x)+\cancelto0{\frac{da_1}{dx}}+\cancelto{2a_2}{\frac{d2a_2x}{dx}}$$
$$f''(x)=g''(x)+2a_2$$
$$f'''(x)=g'''(x)+\cancelto0{\frac{d2a_2}{dx}}$$
$$f'''(x)=g'''(x)$$
So the solution to that DE is given by $(1)$.
For fractional values of $n$, we run into fractional calculus, whereupon I cannot give you any simple answer.
I can say the following:
$$f(x)=g(x)\implies\frac{d^\alpha}{dx^\alpha}f(x)=\frac{d^\alpha}{dx^\alpha}g(x)$$
However,
$$\frac{d^\alpha}{dx^\alpha}f(x)=\frac{d^\alpha}{dx^\alpha}g(x)\cancel\implies f(x)=g(x)$$
If you are interested, you can try to look up some things on fractional calculus, which is concerned with fractional derivatives.
Here is the Wikipedia for fractional calculus, but do be warned that most sources ignore a fractional constant of integration or whatever due to its confusing nature.