Joãozinho collects natural numbers whose unit digit is the sum of the other digits. For example, he collected 10023, because $1+0+0+2=3$.

a) In Joãozinho's collection, there is a number that has 4 digits and whose unit digit is 1. What is this number?

b) What is the largest number without the digit 0 that can appear in the collection?

c) What is the largest number without repeated digits that can appear in the collection?
Solution

a) There are only three ways to write 1 as the sum of three natural numbers: $1=1+0+0, 1=0+1+0$, and $1=0+0+1$, which give us the possibilities 1001, 0101, and 0011. The numbers 0101 and 0011 must be discarded because they do not have four significant digits. Therefore, in Joãozinho's collection, the number 1001 appears.
b) First, we note that if a number with non-zero digits is in the collection, then it has at most 10 digits. Indeed, if it had 11 or more non-zero digits, then the sum of all its digits, except the units digit, would be at least 10, which is not possible since the largest digit is 9. Therefore, all numbers with non-zero digits in the collection have at most 10 digits, which shows that there is a largest number without the digit 0 in the collection. Let's assume that Joãozinho's collection is complete. The number 2316 is in the collection; by replacing the 3 with 111, we get 211116, which is also in the collection and is larger than 2316 because it has more digits. In general, if a number without the digit 0 is in the collection and has a digit other than the units digit that is not 1, we can "stretch" the number by replacing that digit with a sequence of 1's, obtaining a new number that is in the collection and is larger than the first. Therefore, the largest number with non-zero digits in the collection must have all its digits equal to 1, except for the units digit, which is equal to the number of 1's preceding it. Since the largest possible units digit is 9, it follows that the number we are looking for is 1111111119.

We note that the collection can have arbitrarily large numbers with the digit 0, such as (for example) 101, 1001, 10001, and so on.

c) A number in the collection cannot have six distinct digits, because in that case the sum of the five digits to the left of the units digit would be at least $0+1+2+3+4=10$. On the other hand, the collection can have numbers with five distinct digits, such as, for example, 25108. If one of these numbers has a units digit different from 9, we can "increase" it by adding 1 to the units digit and 1 to the ten-thousands digit (which clearly cannot be 9), without leaving the collection. For example, the number 43108 can be "increased" to 53109, which is also in the collection. Therefore, the largest number with five distinct digits in the collection must have 9 as the units digit. It is now sufficient to write 9 as the sum of four distinct terms in descending order to "build" our number; it follows immediately that the desired decomposition is $9=6+2+1+0$ and we obtain the number 62109.