Problem (Number Theory):
Let $f(n)$ be the number of positive integers that have exactly $n$ digits and whose digits have a sum of 5. Determine, with proof, how many of the 2014 integers $f(1), f(2), \ldots, f(2014)$ have a units digit of 1 .

Solution:
First, we prove that $f(n)=\frac{n(n+1)(n+2)(n+3)}{24}$ in two different ways.

Method 1

If an $n$-digit integer has digits with a sum of 5 , then there are several possibilities for the combination of non-zero digits used:

$$
5 \quad 4,1 \quad 3,2 \quad 3,1,1 \quad 2,2,1 \quad 2,1,1,1 \quad 1,1,1,1,1
$$

We count the number of possible integers in each case by determining the number of arrangements of the non-zero digits; we call the number of ways of doing this $a$. (For example, the digits 4 and 1 can be arranged as 41 or 14 .) We then place the leftmost digit in such an arrangement as the leftmost digit of the $n$-digit integer (which must be nonzero) and choose the positions for the remaining non-zero digits among the remaining $n-1$ positions; we call the number of ways of doing this $b$. (For example, for the arrangement 14 , the digit 1 is in the leftmost position and the digit 4 can be in any of the remaining $n-1$ positions.) We fill the rest of the positions with 0s. The number of possible integers in each case will be $a b$, since this method will create all such integers and for each of the $a$ arrangements of the non-zero digits, there will be $b$ ways of arranging the digits after the first one. We make a chart to summarize the cases, expanding each total and writing it as a fraction with denominator 24 :

| Case | $a$ | $b$ | $a b$ (expanded) |
| :---: | :---: | :---: | :--- |
| 5 | 1 | 1 | $1=\frac{24}{24}$ |
| 4,1 | 2 | $(n-1)$ | $2(n-1)=\frac{48 n-48}{24}$ |
| 3,2 | 2 | $(n-1)$ | $2(n-1)=\frac{48 n-48}{24}$ |
| $3,1,1$ | 3 | $(<<f17031409419463268>>$)$ | $3(<<f170314094194688001>>$)=\frac{36 n^{2}-108 n+72}{24}$ |
| $2,2,1$ | 3 | $(<<f170314094194618352>>$)$ | $3(<<f170314094194638371>>$)=\frac{36 n^{2}-108 n+72}{24}$ |
| $2,1,1,1$ | 4 | $(<<f170314094194693288>>$)$ | $4(<<f17031409419469862>>$)=\frac{16 n^{3}-96 n^{2}+176 n-96}{24}$ |
| $1,1,1,1,1$ | 1 | $(<<f170314094194686986>>$)$ | $(<<f17031409419465818>>$)=\frac{n^{4}-10 n^{3}+35 n^{2}-50 n+24}{24}$ |

(Note that in the second and third cases we need $n \geq 2$, in the fourth and fifth cases we need $n \geq 3$, in the sixth case we need $n \geq 4$, and the seventh case we need $n \geq 5$. In each case, though, the given formula works for smaller positive values of $n$ since it is equal to 0 in each case. Note also that we say $b=1$ in the first case since there is exactly 1 way of placing $0 \mathrm{~s}$ in all of the remaining $n-1$ positions.)

$f(n)$ is then the sum of the expressions in the last column of this table, and so

$$
f(n)=\frac{n^{4}+6 n^{3}+11 n^{2}+6 n}{24}=\frac{n(n+1)(n+2)(n+3)}{24}
$$

as required.

Method 2

First, we create a correspondence between each integer with $n$ digits and whose digits have



a sum of 5 and an arrangement of five 1 s and $(n-1)$ Xs that begins with a 1 .

We can then count these integers by counting the arrangements.

Starting with such an integer, we write down an arrangement of the above type using the following rule:

The number of 1 s to the left of the first $\mathrm{X}$ is the first digit of the number, the number of 1 s between the first $\mathrm{X}$ and second $\mathrm{X}$ is the second digit of the number, and so on, with the number of 1 s to the right of the $(n-1)$ st $\mathrm{X}$ representing the $n$th digit of the number.

For example, the integer 1010020001 would correspond to 1XX1XXX11XXXX1.

In this way, each such integer gives an arrangement of the above type.

Similarly, each arrangement of this type can be associated back to a unique integer with the required properties by counting the number of 1 s before the first $\mathrm{X}$ and writing this down as the leftmost digit, counting the number of 1 s between the first and second Xs and writing this down as the second digit, and so on. Since a total of five 1s are used, then each arrangement corresponds with an integer with $n$ digits whose digits have a sum of 5 . Therefore, there is a one-to-one correspondence between the integers and arrangements with the desired properties.

Thus, $f(n)$, which equals the number of such integers, also equals the number of such arrangements.

To count the number of such arrangements, we note that there are four 1 s and $n-1 \mathrm{Xs}$ to arrange in the final $4+(n-1)=n+3$ positions, since the first position is occupied by a 1 .

There are $\left(\begin{array}{c}n+3 \\ 4\end{array}\right)$ ways to choose the positions of the remaining four 1s, and so $\left(\begin{array}{c}n+3 \\ 4\end{array}\right)$ arrangements.

Thus, $f(n)=\left(\begin{array}{c}n+3 \\ 4\end{array}\right)=\frac{(n+3) !}{4 !(n-1) !}=\frac{(n+3)(n+2)(n+1)(n)}{4 !}=\frac{n(n+1)(n+2)(n+3)}{24}$.

Next, we need to determine the positive integers $n$ between 1 and 2014, inclusive, for which the units digit of $f(n)$ is 1 .

Now $f(n)=\frac{n(n+1)(n+2)(n+3)}{24}$ is an integer for all positive integers $n$, since it is counting the number of things with a certain property.

If the units digit of $n$ is 0 or 5 , then $n$ is a multiple of 5 .

If the units digit of $n$ is 2 or 7 , then $n+3$ is a multiple of 5 .

If the units digit of $n$ is 3 or 8 , then $n+2$ is a multiple of 5 .

If the units digit of $n$ is 4 or 9 , then $n+1$ is a multiple of 5 .

Thus, if the units digit of $n$ is $0,2,3,4,5,7,8$, or 9 , then $n(n+1)(n+2)(n+3)$

is a multiple of 5 and so $f(n)=\frac{n(n+1)(n+2)(n+3)}{24}$ is a multiple of 5 , since the denominator contains no factors of 5 that can divide the factor from the numerator.

Therefore, if the units digit of $n$ is $0,2,3,4,5,7,8$, or 9 , then $f(n)$ is divisible by 5 , and so cannot have a units digit of 1 .

So we consider the cases where $n$ has a units digit of 1 or of 6 ; these are the only possible values of $n$ for which $f(n)$ can have a units digit of 1 .

We note that $3 f(n)=\frac{n(n+1)(n+2)(n+3)}{8}$, which is a positive integer for all positive integers $n$.



Also, we note that if $f(n)$ has units digit 1 , then $3 f(n)$ has units digit 3 , and if $3 f(n)$ has units digit 3 , then $f(n)$ must have units digit 1 .

Therefore, determining the values of $n$ for which $f(n)$ has units digit 1 is equivalent to determining the values of $n$ for which $\frac{n(n+1)(n+2)(n+3)}{8}$ has units digit 3 .

We consider the integers $n$ in groups of 40 . (Intuitively, we do this because the problem seems to involve multiples of 5 and multiples of 8 , and $5 \times 8=40$.)

If $n$ has units digit 1 , then $n=40 k+1$ or $n=40 k+11$ or $n=40 k+21$ or $n=40 k+31$ for some integer $k \geq 0$.

If $n$ has units digit 6 , then $n=40 k+6$ or $n=40 k+16$ or $n=40 k+26$ or $n=40 k+36$ for some integer $k \geq 0$.

If $n=40 k+1$, then

$$
\begin{aligned}
3 f(n) & =\frac{n(n+1)(n+2)(n+3)}{8} \\
& =\frac{(40 k+1)(40 k+2)(40 k+3)(40 k+4)}{8} \\
& =(40 k+1)(20 k+1)(40 k+3)(10 k+1)
\end{aligned}
$$

The units digit of $40 k+1$ is 1 , the units digit of $20 k+1$ is 1 , the units digit of $40 k+3$ is 3 , and the units digit of $10 k+1$ is 1 , so the units digit of the product is the units digit of $(1)(1)(3)(1)$ or 3.

In a similar way, we treat the remaining seven cases and summarize all eight cases in a chart:

| $n$ | $3 f(n)$ simplified | Units digit of $3 f(n)$ |
| :---: | :---: | :---: |
| $40 k+1$ | $(40 k+1)(20 k+1)(40 k+3)(10 k+1)$ | 3 |
| $40 k+11$ | $(40 k+11)(10 k+3)(40 k+13)(20 k+7)$ | 3 |
| $40 k+21$ | $(40 k+21)(20 k+11)(40 k+23)(10 k+6)$ | 8 |
| $40 k+31$ | $(40 k+31)(10 k+8)(40 k+33)(20 k+17)$ | 8 |
| $40 k+6$ | $(20 k+3)(40 k+7)(10 k+2)(40 k+9)$ | 8 |
| $40 k+16$ | $(10 k+4)(40 k+17)(20 k+9)(40 k+19)$ | 8 |
| $40 k+26$ | $(20 k+13)(40 k+27)(10 k+7)(40 k+29)$ | 3 |
| $40 k+36$ | $(10 k+9)(40 k+37)(20 k+19)(40 k+39)$ | 3 |

(Note that, for example, when $n=40 k+16$, the simplified version of $3 f(n)$ is $(10 k+4)(40 k+17)(20 k+9)(40 k+19)$, so the units digit of $3 f(n)$ is the units digit of $(4)(7)(9)(9)$ which is the units digit of 2268 , or 8 .)

Therefore, $f(n)$ has units digit 1 whenever $n=40 k+1$ or $n=40 k+11$ or $n=40 k+26$ or $n=40 k+36$ for some integer $k \geq 0$.

There are 4 such integers $n$ between each pair of consecutive multiples of 40 .

Since $2000=50 \times 40$, then 2000 is the 50 th multiple of 40 , so there are $50 \times 4=200$ integers $n$ less than 2000 for which the units digit of $f(n)$ is 1 .

Between 2000 and 2014, inclusive, there are two additional integers: $n=40(50)+1=2001$ and $n=40(50)+11=2011$.

In total, 202 of the integers $f(1), f(2), \ldots, f(2014)$ have a units digit of 1 .

Final answer: 202