## Task A-4.5.

Determine all functions $f: \mathbb{N} \times \mathbb{N} \rightarrow \mathbb{N}$ that satisfy the following two conditions.

- For all $a, b \in \mathbb{N}$, we have

$$
f(a, b) + a + b = f(a, 1) + f(1, b) + ab \text{.}
$$

- If $a, b \in \mathbb{N}$ are such that one of the numbers $a+b$ and $a+b-1$ is divisible by a prime number $p > 2$, then $f(a, b)$ is also divisible by $p$.
## First Solution.

By substituting $(a, b)=(1,1)$ into the equality from the first condition, we get $f(1,1)=1$.

Let's look at the equation from the first condition for the pairs of numbers $(a, b)$ and $(a, b+1)$, and then subtract. After rearranging, we get

$$
f(a, b+1)-f(a, b)=f(1, b+1)-f(1, b)+a-1
$$

Let $p>2$ be a prime number that divides $a+b$. From the second condition, we get that both expressions on the left side of the equation are divisible by $p$, so the right side of the equation is also divisible by $p$. Furthermore, since $a+b$ is divisible by $p$, we get

$$
p \mid f(1, b+1)-f(1, b)-b-1
$$

for any two natural numbers $a, b$, and for any prime number $p>2$ that divides $a+b$. Fix some natural number $b$. Since the expression on the right side does not depend on $a$, by choosing different values for $a$ and different odd prime divisors of $a+b$, we see that the expression $f(1, b+1)-f(1, b)-b-1$ is divisible by infinitely many prime numbers, which is only possible if this expression is equal to zero. Thus, we have

$$
f(1, b+1)=f(1, b)+b+1
$$

for any natural number $b$.

From here, we see that for any natural number $n$,

$$
\begin{aligned}
f(1, n) & =f(1, n-1)+n=f(1, n-2)+(n-1)+n=\ldots \\
& =f(1,1)+2+3 \cdots+n=1+2+3 \cdots+n=\frac{n(n+1)}{2}
\end{aligned}
$$

In the same way, we can conduct the argument by subtracting the equation from the first condition for the pairs of numbers $(a+1, b)$ and $(a, b)$, and obtain that

$$
f(n, 1)=\frac{n(n+1)}{2}
$$

for all natural numbers $n$.

By substituting the formulas for $f(1, n)$ and $f(n, 1)$ into the first condition, we get that for any two natural numbers $a, b$,

$$
f(a, b)=\frac{a(a+1)}{2}+\frac{b(b+1)}{2}+a b-a-b=\frac{(a+b)(a+b-1)}{2}=\binom{a+b}{2}
$$

The function defined this way satisfies the second condition as well, so we conclude that this is the only solution.