## Task 4.

Determine all pairs $(k, n)$ of natural numbers that satisfy the equation

$$
1!+2!+\ldots+k!=1+2+\ldots+n
$$

(We denote by $b!$ the product of the first $b$ natural numbers. For example, $4!=1 \cdot 2 \cdot 3 \cdot 4=24$.)
## First Solution.

Consider the remainders when dividing both sides of the equation by 7.

For the left side, we can observe:

| $k$ | 1 | 2 | 3 | 4 | 5 | 6 | 7 | $\ldots$ |
| :--- | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :--- |
| $k!(\bmod 7)$ | 1 | 2 | 6 | 3 | 1 | 6 | 0 | $\ldots$ |
| $1!+\ldots+k!(\bmod 7)$ | 1 | 3 | 2 | 5 | 6 | 5 | 5 | $\ldots$ |

For $k \geqslant 7$, $k!$ is divisible by 7, so $1!+\ldots+k!$ gives a remainder of 5 when divided by 7.

We also have the following remainders when dividing by 7:

| $n$ | 1 | 2 | 3 | 4 | 5 | 6 | 7 | $\ldots$ |
| :--- | :--- | :--- | :--- | :--- | :--- | :--- | :--- | :--- |
| $1+\ldots+n(\bmod 7)$ | 1 | 3 | 6 | 3 | 1 | 0 | 0 | $\ldots$ |

The remainders when dividing by 7 repeat periodically with a period of 7, so the remainders given by the sums of the first $n$ numbers will also repeat with the same period.

For some $k$ and $n$ to have equality, the only possibilities are that both sides of the equation give remainders of 1, 3, and 6 when divided by 7.

This will happen for $k=1,2,5$. For each $k$, there is only one possible solution for $n$, as the sum of the first $n$ natural numbers increases with $n$.

For $k=1$, the solution is $n=1$, for $k=2$ the solution is $n=2$, and for $k=5$ the solution is $n=17$.

Thus, all solutions are given by $(k, n)=(1,1)$, $(k, n)=(2,2)$, and $(k, n)=(5,17)$.