Let n be fixed. Consider the number that is obtained by increasing or decreasing one of its digits by i, i.e., the number n±bi where b=10k for some k. Then
S(n±bi)n±bi>S(n)n⟺S(n)±in±bi>S(n)n⟺nn±bi>S(n)S(n)±i⟺1±nbi>1±S(n)i⟺±nbi>±S(n)i⟺±b>±S(n)n.
The last inequality is equivalent to S(n)n<b in the case of plus and to S(n)n>b in the case of minus.
This shows that no number n with the property described in the problem can contain digits 2 through 8. Otherwise, this digit could be both increased and decreased leading to contradictory conclusions since the ratio of the number and its sum of digits increases in both cases.
It remains to show that the numbers with the desired property can contain digits 0, 1, 9. For that, we prove that 1099 has the desired property. Let n=d3d2d1d0 be an arbitrary 4-digit number. For arbitrary positive integer x, denote R(x)=S(x)x.
If d0<9 then the last digit can be increased. As d3>0 implies
R(d3d2d19)=d3+d2+d1+91000d3+100d2+10d1+9>1,
we obtain R(d3d2d19)<R(n).
If d1<9 then the tens digit can be increased. As
R(d3d299)=d3+d2+9+91000d3+100d2+99>9+9+9+91000>1001000=10,
If d3>1 then the thousands digit can be decreased. As
R(1d299)=1+d2+9+91000+100d2+99<99000=1000,
we obtain R(1d299)<R(d3d299).
Finally if d2>0 then the hundreds digit can be decreased. As
R(1099)=191099<100,
we obtain R(1099)<R(1d299). Consequently,
R(1099)≤R(1d299)≤R(d3d299)≤R(d3d2d19)≤R(n),
whereby all equalities hold simultaneously only if n=1099. This completes the proof.