<s>[INST] Ratio and number theory The question goes as follows:

Let $K$ be a three digit number such that the ratio of the number to the sum
  of its digit is least.  What is the difference between the hundreds and
  the tens digits of $K$?

Now I was able to do this question by trial and error, assuming hundredth digit place to be 1 and unit as well as tens digit to be 9
So the number is 199, but I am not able to do it logically, any way to do it?
 [/INST] Doing it in a single function, just for fun:
For $x \in \mathbb{Z}$ we want to minimize the ratio $\frac{100a+10b+c}{a+b+c}$ where $ a,b,c\in\mathbb{Z}$ and $100a+10b+c=x$  We can rewrite the ratio as:  $$ f(x)=\frac{100\left\lfloor\frac{x}{100}\right\rfloor+10\left\lfloor\frac{x-100\left\lfloor\frac{x}{100}\right\rfloor}{10}\right\rfloor+\left\lfloor x-100\left\lfloor\frac{x}{100}\right\rfloor-10\left\lfloor\frac{x-100\left\lfloor\frac{x}{100}\right\rfloor}{10}\right\rfloor\right\rfloor}{\left\lfloor\frac{x}{100}\right\rfloor+\left\lfloor\frac{x-100\left\lfloor\frac{x}{100}\right\rfloor}{10}\right\rfloor+\left\lfloor x-100\left\lfloor\frac{x}{100}\right\rfloor-10\left\lfloor\frac{x-100\left\lfloor\frac{x}{100}\right\rfloor}{10}\right\rfloor\right\rfloor}$$
Which, when graphed, gives: 
which clearly is minimized at 199 (or 1-9 if the $x$ is allowed to have two leading $0$s) 
</s>