In the pattern shown below, row 1 (the bottom row) consists of two 1 's, and row $n$ is formed by taking row $n-1$ and inserting between each adjacent pair of numbers $a$ and $b$ their sum $a+b$ :

| 1 | 5 | 4 | 7 | 3 | 8 | 5 | 7 | 2 | 7 | 5 | 8 | 3 | 7 | 4 | 5 | 1 |
| :--- | :--- | :--- | :--- | :--- | :--- | :--- | :--- | :--- | :--- | :--- | :--- | :--- | :--- | :--- | :--- | :--- |
| 1 |  | 4 |  | 3 |  | 5 |  | 2 |  | 5 |  | 3 |  | 4 |  | 1 |
| 1 |  |  |  | 3 |  |  |  | 2 |  |  |  | 3 |  |  |  | 1 |
| 1 |  |  |  |  |  |  |  | 2 |  |  |  |  |  |  |  | 1 |
| 1 |  |  |  |  |  |  |  |  |  |  |  |  |  |  | 1 |  |
| 1 |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |

In row 2019 of the pattern, how many copies of 2019 will there be?
The number of copies of $n$ in row $n$ is $\phi(n)$, where $\phi$ is the totient function, or the number of positive integers less than or equal to $n$ that are relatively prime to $n$. To see this, consider the following pattern of fractions, where we start with $\frac{0}{1}$
and $\frac{1}{1}$ and insert $\frac{a+c}{b+d}$ between $\frac{a}{b}$ and $\frac{c}{d}$ :

![](https://cdn.mathpix.com/cropped/2024_04_17_fc198c8f5ad8c9012196g-4.jpg?height=408&width=985&top_left_y=367&top_left_x=587)

The denominators of these fractions form the pattern of numbers in the problem, and the fractions are in increasing order. Row $n$ contains all the fractions in the $n$th Farey sequence exactly once, i.e. all the fractions with denominator at most $n$ (plus some other fractions). Thus, the number of copies of $n$ in row $n$ equals the number of fractions between 0 and 1 with denominator $n$ in simplest form. Each of these fractions must have numerator less than or equal to $n$ and relatively prime to $n$, so there are $\phi(n)$ such fractions. Thus, there are $\phi(n)$ copies of $n$ in row $n$.

The prime factorization of 2019 is $3 \cdot 673$, thus in row 2019 the number of copies of 2019 is

$$
\phi(2019)=2019\left(1-\frac{1}{3}\right)\left(1-\frac{1}{673}\right)=2 \cdot 672=1244
$$