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?
 A: Let the number be $100a + 10 b +c$, where $1 \leq a \leq 9$ and $0 \leq b,c, \leq9$. Hence, we want to minimize
$$L=\dfrac{100a + 10b + c}{a+b+c} = 1 + \dfrac{99a+9b}{a+b+c}$$
This means that you should choose $c$ to be maximum as possible since $c$ appears only in the denominator and the term is positive. Hence, $c = 9$. Hence, we want to minimize $$L=\dfrac{100a + 10b + c}{a+b+c} = 1 + \dfrac{99a+9b}{a+b+9} = 1 + \dfrac{90a - 81 + 9a+ 9b + 81}{a+b+9}$$
$$L = 1 + \dfrac{90a-81}{a+b+9} + 9 = 10 + 9 \left(\dfrac{10a-9}{a+b+9} \right)$$
Now again you should choose $b$ to be maximum as possible since $b$ appears only in the denominator and the term is positive. Hence, set $b=9$. Hence, we want to minimize $$L = 10 +9 \left( \dfrac{10a-9}{a+18} \right) = 10 +9 \left( \dfrac{10a + 180 -189}{a+18} \right) = 10 + 90 - \dfrac{9 \times 189}{a+18}$$
Now you ned to choose $a$ to be minimum as possible since $a$ appears in the denominator and the term is negative. Hence, set $a = 1$. Hence, $$L = 100 - \dfrac{9 \times 189}{19} = \dfrac{1900 - 9 \times 189}{19} = \dfrac{199}{19}$$ The number is $199$.
A: 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) 
A: We want $a>0,b\geq 0,c\geq 0$, $a,b,c\leq 9$ s.t. $r = \frac{(100a+10b+c)}{(a+b+c)}$ is minimum.
$r = 1 + \frac{(99a+9b)}{(a+b+c)}$.
For a given $a$ and $b$, this is least when $c$ is maximum, i.e. $9$.
Now given $c=9,  r = 1 + \frac{(99a+9b)}{(a+b+9)}
= 1 + 9 + \frac{(90a-9)}{(a+b+9)}$.
Again, we see this is least given $a$ when $b$ is maximum, i.e. $9$.
Now, given $b=c=9$,
$r = 10+\frac{(90a-9)}{(a+18)}$
$\frac{(r-10)}{9}=\frac{(10a-1)}{(a+18)}$
$= \frac{(10a+180-179)}{(a+18)}$
$= 10 - \frac{179}{(a+18)}$.
Clearly, this is least when a has the least possible value, i.e. 1.
