27*. How many positive integer solutions does the equation

$$
x+y+z=n
$$

have that satisfy the inequalities

$$
x \leqslant y+z, \quad y \leqslant x+z, \quad z \leqslant x+y ?
$$
27. Since $z=n-x-y$, the solution will be fully determined if we know $x$ and $y$. Substituting $n-x-y$ for $z$ in our inequalities:
1) The inequality $z \leqslant x+y$ gives

$$
n-x-y \leqslant x+y
$$

from which

$$
n \leqslant 2(x+y) ; \quad x+y \geqslant \frac{n}{2}
$$

i.e.

$$
y \geqslant \frac{n}{2}-x
$$

2) The inequality $y \leqslant x+z$ gives

$$
y \leqslant x+n-x-y
$$

from which

$$
2 y \leqslant n, \quad y \leqslant \frac{n}{2}
$$

From 1) and 2) it follows that for each fixed value of $x$ there are as many different solutions as there are positive integers between $\frac{n}{2}-x$ and $\frac{n}{2}$.

3) The inequality $x \leqslant y+z$ gives

$$
x \leqslant y+n-x-y
$$

from which

$$
2 x \leqslant n, \quad x \leqslant \frac{n}{2}
$$

Thus, $x$ can vary from 1 to $\left[\frac{n}{2}\right]$.

In addition to these inequalities, $x$ and $y$ must also satisfy the inequality $x+y<n$. $n$ is even.

Let's consider the two possible cases: $n$ is odd and $n$ is even.

1) $n$ is odd. Then $x$ can take the values $\left[\frac{n}{2}\right]=\frac{n-1}{2}, \frac{n-1}{2}-1, \frac{n-1}{2}-2, \ldots, 1$

and for each of these values of $x$, the number of positive integers between $\frac{n}{2}-x$ and $\frac{n}{2}$ is $x$ (these conditions are satisfied by the numbers $\frac{n-1}{2}, \frac{n-1}{2}-1$, $\left.\ldots, \frac{n-1}{2}-(x-1)\right)$. Therefore, for

there are $\frac{n-1}{2}$ different solutions ( $y$ can be $\frac{n-1}{2}$; $\left.\frac{n-3}{2} ; \ldots ; 1\right) ;$ for

$$
x=\frac{n-1}{2}-1
$$

there are $\frac{n-1}{2}-1$ different solutions ( $y$ can be $\frac{n-1}{2}$, $\frac{n-1}{2}-1, \ldots, 2$ ), and so on; for $x=1$ there is only one solution ( $y$ must be $\frac{n-1}{2}$ ). It is clear that the condition $x+y<n$ is satisfied for all these solutions. Finally, the total number of different positive integer solutions to the equation $x+y+z=n$, satisfying the given inequalities, in this case is

$$
\frac{n-1}{2}+\frac{n-3}{2}+\ldots+1=\frac{\frac{(n-1)}{2} \cdot\left[\frac{n-1}{2}+1\right]}{2}=\frac{n^{2}-1}{8}
$$

2) $n$ is even. Here $x$ can take the values $\left[\frac{n}{2}\right]=\frac{n}{2}$, $\frac{n}{2}-1, \frac{n}{2}-2, \ldots, 1$. For $x=\frac{n}{2}$, the number of positive integers

$\frac{n}{2}=x$ (these conditions are satisfied by the numbers $\left.\frac{n}{2}, \frac{n}{2}-1, \ldots, 1\right)$, and for $x<\frac{n}{2}$, the number of positive integers between $\frac{n}{2}-x$ and $\frac{n}{2}$ is $x+1$ (these conditions are satisfied by the numbers $\frac{n}{2}, \frac{n}{2}-1, \ldots, \frac{n}{2}-x$; for $x=\frac{n}{2}$, the number of solutions is only $x$, since the number $\frac{n}{2}-x=0$ is not positive and must be discarded). Thus, for $x=\frac{n}{2}$ there are $\frac{n}{2}$ different solutions ( $y$ can be $\left.\frac{n}{2}, \frac{n}{2}-1, \ldots, 1\right)$; for $x=\frac{n}{2}-1$ there are also $\frac{n}{2}$ different solutions ( $y$ can be $\left.\frac{n}{2}, \frac{n}{2}-1, \ldots, 1\right)$, and so on; finally, for $x=1$ there are two different solutions ( $y$ can be $\frac{n}{2}$ or $\frac{n}{2}-1$ ). From all these solutions, one (namely, $x=\frac{n}{2}$, $y=\frac{n}{2}$ ) must be discarded, as it does not satisfy the condition $x+y<n$. Thus, in this case, the total number of different positive integer solutions to the equation $x+y+z=n$, satisfying the given inequalities, is

$$
\begin{aligned}
& \frac{n}{2}+\frac{n}{2}+\left(\frac{n}{2}-1\right)+\left(\frac{n}{2}-2\right)+\ldots+2-1= \\
& =\left(\frac{n}{2}+1\right)+\frac{n}{2}+\left(\frac{n}{2}-1\right)+\left(\frac{n}{2}-2\right)+\ldots+2+1-3= \\
& =\frac{\left(\frac{n}{2}+1\right)\left(\frac{n}{2}+2\right)}{2}-3=\frac{(n+2)(n+4)}{8}-3= \\
& =\frac{n^{2}+6 n-16}{8}=\frac{(n+8)(n-2)}{8} .
\end{aligned}
$$

Note that the condition of the problem can also be interpreted geometrically. Each integer solution to the equation $x+y+z=n$ is fully determined by two integers $x$ and $y$ (since $z=n-x-y$ is uniquely determined by $x$ and $y$). Let's consider a Cartesian coordinate system on a plane and mark all points with integer coordinates $x$ and $y$ that are solutions to our problem (Fig. 36). We have seen that for such solutions, $y \leqslant \frac{n}{2}$; therefore, all points corresponding to these conditions must lie below the line $N P\left(O N=M P=\frac{n}{2}\right)$ or on it. Due to the inequality $x \leqslant \frac{n}{2}$, all these points must lie to the left of the line $P M\left(O M=N P=\frac{n}{2}\right)$ or on it. Finally, the inequality $x+y \geq \frac{n}{2}$ shows that all these points lie above the line $N M$ or on it.

![](https://cdn.mathpix.com/cropped/2024_05_21_68334347b64402497ba5g-131.jpg?height=464&width=470&top_left_y=517&top_left_x=185)

Fig. 36. Thus, all the points we are looking for must be located inside or on the sides of the triangle $N P M$, shaded in Fig. 36; the vertices $N, P$ and $M$ of the triangle do not count (even if their coordinates are integers), because for them one of the numbers $x, y, z$ becomes zero.

It is easy to see that conversely, all points of the triangle $N P M$ with integer coordinates (except the vertices) correspond to positive integer solutions to the equation $x+y+z=n$, satisfying the inequalities $x+y \geqslant z$, $x+z \geqslant y, y+z \geqslant x$. Thus, our problem can also be formulated as follows:

On a plane with a Cartesian coordinate system, the lines $x=\frac{n}{2}, y=\frac{n}{2}$ and $x+y=\frac{n}{2}$ are drawn. How many points with integer coordinates are located inside and on the sides of the triangle bounded by these lines (vertices are not counted)?