If x was a positive 4 digit number and you divide it by the sum of its digits to get the smallest value possible, what is the value of x? For example (1234 = 1234/10)
I got 1099 as my answer however I don't know if this is right or how to prove it.
Let $x$ be the 4-digit number ending in digit not equal to 9 with the sum of digits equal to $s$. If you increase the last digit by one, the number becomes $x+1$ and the sum of digits becomes $s+1$.
You can easily prove that:
$$\frac xs>\frac{x+1}{s+1}$$
This is true because $x>s$. So to reduce the ratio as much as possible, the last digit has to be as big as possible, which is $9$.
Now consider number $x$ with the third digit not eqaul to 9. Increase the third digit by one and the number becomes $x+10$ and the sum increases by 1. Again, you can show that:
$$\frac xs>\frac{x+10}{s+1}$$
This is true because $x>10s$. So the third digit also has to be as big as possibe. So the last two digits must be equal to 9.
Consider now the first digit and decrease it by one. The number becomes $x-1000$ and the sum becomes $s-1$.
$$\frac xs>\frac{x-1000}{s-1}$$
This is true because it is equivalent to:
$$x<1000s$$
...and you know that $s$ is certainly greater than 18 (the last two digits must be 9). So the first digit has to be as small as possible i.e. 1 and the number is of the form:
$$1a99$$
The ratio you want to minimize now becomes:
$$\frac{100a+1099}{a+19}=100-\frac{801}{a+19}$$
Minimum value is reached for minumum value of $a$ which is 0. So the solution is: 1099.
The answer 1099 is confirmed by the following MiniZinc model:
% decision variable array
array[1..4] of var 0..9: digits;
var int: objective = sum([digits[i] * pow(10, i-1) | i in 1..4]) div sum(digits);
constraint digits[4] > 0; % otherwise, there would be less than 4 digits
solve minimize objective;
Write the $4$-digit number as $x = 1000a+100b+10c+d$, where $a,b,c,d$ are integers from $0$ to $9$ (and $a \neq 0$.)
You want to minimize $A = \dfrac{1000a+100b+10c+d}{a+b+c+d}$, which can be written as $$ \begin{align*} A &= \dfrac{999a+99b+9c}{a+b+c+d}+1\\ &\geq \dfrac{999a+99b+9c}{a+b+c+9} + 1 & \text{(since the numerator} > 0\text{, set } d = 9)\\ &= \dfrac{990a+90b-81}{a+b+c+9} + 10\\ &\geq \dfrac{990a+90b-81}{a+b+9+9} + 10 & \text{(since the numerator} > 0\text{, set } c = 9)\\ &= \dfrac{900a-18\times90-81}{a+b+9+9} + 100\\ &= \dfrac{900a-1701}{a+b+18} + 100\\ &\geq \dfrac{900\times 1-1701}{1+b+18} + 100 & \text{(since the } \textbf{denominator} > 0\text{, set } a = 1)\\ &\geq \dfrac{900-1701}{1+0+18} + 100, & \text{(since the numerator} < 0\text{, set } b = 0)\\ \end{align*} $$ and the minimum attains when $x = 1099$.
I used Python to prove that shortest posible value is '1099'.
m = []
for eve in range(1000, 10000):
nums = list(map(int, list(str(eve))))
m.append((nums, eve / sum(nums)))
m.sort(key=lambda x: x[1])
print(m[0])
print(min((n/sum(int(d)for d in str(n)),n)for n in range(1000,10000))[1])
73 bytes :)
$\endgroup$
k
digit numbers you get the sequence $1,19,199,1099,10999,109999,1099999 ... $ I've verified the pattern out to $k = 8$ (after which I no longer have the patience to run my code). There is a natural conjecture, which could perhaps be proved by induction. $\endgroup$