Recently I ran across a fun little problem about numbers at Ben Orlin’s blog https://mathwithbaddrawings.com/2019/11/18/the-anti-calculator-puzzle/. My rephrasing of it is as follows:

Consider every positive integer which can be represented in base as a -digit number. In other terms, we have

, (1)

where and for . We can then define the function f(n) over all d-digit numbers as

, (2)

i.e. the original number divided by the sum of its digits. The goal of the problem is to find the maxima and minima of this function over all -digit numbers.

Finding the maximum value of is relatively simple; a little numerical experimentation and thinking shows that the sum of digits is always larger than or equal to the first digit, and thus heuristically we can say that the denominator can drag the whole sum down to be less than or equal to . More rigorously, we can rearrange the expression into the form

. (3)

(Note that in the numerator of expression 3, the value of fell out of the sum. This is going to be a recurring theme of this discussion later on.)

Because every term in expression 3 is either positive or zero for , and only zero if is zero, we can see that the maximum value of is in fact , which is only realized when all digits of but the first are zero.

That was the easy part. Finding the minimum (and there is only one, as it turns out) is rather more subtle. While it is tempting to assume that the correct answer will be numbers of the form where , this can quickly be proven false using four-digit numbers in base ten. In base ten, , , and . Clearly we must look more deeply.

First, I will describe the solution: over all -digit natural numbers, function as defined in expression (2) has a minimum only when 's base- representation is of the form

, (4)

where the number of digits that are equal to is given by the smallest integer such that

. (5)

Note that for small , despite my representation in expression (4), there may actually be no or one zeros present in the true minimum. By the same token, there may be only one or two digits of . However, inspection of expression (5) shown that the number of zeros present is non-decreasing in the number of digits and eventually you will get an arbitrarily large number of zeros, albeit with a far vaster number of ‘s.

To prove (4) and (5), we will focus all of our attention on what I mentally label “the components of the discrete gradient” of . That is, we consider the change induced in by either increasing or decreasing a single digit. Obviously this would produce problems if we step outside of the valid range of digits (i.e. and for ), so we simply forbid taking such steps. All this said, the change in given a single-digit change at position of sign can be calculated to be

. (6)

The most important thing to notice about the numerator on the right side of expression (6) is that it does not depend on the value of , which means that the sign of is constant as we range from 0 to e. Thus either is constant as we change (if ) or the extremes values occur at the boundary points: or for the first digit or or or for the rest of the digits.

We can go a step further and notice that in the special case and , the right side of (5) must be negative or zero, because then all . From expression 3, we know that the true minimum must have at least one non-zero digit after the first (because all which end in anything besides n-1 zeros produce a that is less than ). Thus the first digit of the true minimum must be one, because if it were greater than one, we could simply decrease the first digit and thus decrease . Put another way, is slanted towards smaller , and so all minima must slide there.

I then claim that

for any . (7)

I prove this below, but first observe that expression (7) combined with expression (6) gets us to the form described in equation (4), although not yet expression (5). As noted above, if is not 0 for a particular digit (given the rest of the number), then will change monotonically in that digit, thus producing extrema only at the boundaries. Thus besides the first digit, any minimum can only contain the digits or . We can get further by noting that exchanging digits with different values changes the numerator of in expression 2 but does not change the denominator (the sum of digits) at all. Thus for numbers represented by the same sets of digits, the smaller ones will have the smaller values for . Thus we need consider only numbers of the form of expression (4) as candidates for the true minimum. Finding the correct number of zeros will be the bulk of the solution once I have proved (7).

Expression (7) can be proved true by contradiction. If we assume there is a zero solution to (7), we can rearrange it to get the expression

for any . (8)

But the right-hand side of (8) is an integer which, in base ends in zeros. This proves that for any solution to formula 8, for . But this in turn implies that we can subtract coefficients of on the right size of (8) from the coefficients of on the left, resulting in

for any . (9)

But the left-hand side of formula 9 is positive (because and for every term). Thus there is no valid solution for equation (8) and equation (7) is proved.

The number of zeros and ‘s in the true global minimum can again fortunately be found from a detailed inspection of the consequences of expression (6). In particular, we consider all -digit numbers of the form shown in expression (4). In particular we will look at how changes as you change from (with ‘s) into (with ‘s). We will find that for this case, the numerator of expression (6), whose sign is the sign of the change in for this transition, starts out as negative when all the digits are zero, but increases monotonically as the number of ‘s are increased. The digit for which the numerator of expression (6) becomes positive is the last digit for which you can add another and expect to decrease, and is thus the number of digits of which produces a minimum in , now known to be unique.

To calculate the sign of the change in when transitioning between having digits set to and having digits set to , we extract the numerator from expression (6) and rewrite it in our case as

. (10)

But can be expanded, and most of the terms cancelled, to get $k^r-1$, and so we can transform expression (10) into

. (11)

From this, we can see that the right side of expression (11) starts at negative numbers for and increases monotonically in . If we then use polynomial factorization to factorize out of both terms on the right side of expression (11), we then see that does indeed start increasing and continues increasing once expression (5) is satisfied. q.e.d.