## 17. ILLUSTRATIVE EXERCISE

A positive integer is called triangular if it can be written in the form $\frac{n(n+1)}{2}$ for some positive integer $n$. How many pairs $(a, b)$ of triangular numbers are there such that $b-a=2007$? (It is recalled that 223 is a prime number).

SOLUTION
17. There are 6 pairs of triangular numbers that satisfy the required condition. The problem is equivalent to finding pairs of positive integers $(n, m)$ such that

$$
\frac{n(n+1)}{2}-\frac{m(m+1)}{2}=2007.
$$

Indeed, since different values of $n$ determine different values of $\frac{n(n+1)}{2}$, determining the triangular numbers $a$ and $b$ is equivalent to determining the values of $n$ and $m$ that generate them.

By removing the denominators and factoring, the equation becomes

$$
(n-m)(n+m+1)=2 \cdot 2007=2 \cdot 3^{2} \cdot 223.
$$

Since $n>0, m>0$, and therefore $n+m+1>0$, $n-m$ must also be positive. The equation (4) then represents a way to write $2 \cdot 2007$ as a product of two positive integers. But the only ways to break down $2 \cdot 3^{2} \cdot 223$ as a product of two positive integers are obtained by "distributing" all possible ways of its prime factors between the two integers, explicitly:

- 1 and $2 \cdot 3 \cdot 3 \cdot 223$;
- 2 and $3 \cdot 3 \cdot 223$;
- 3 and $2 \cdot 3 \cdot 223$;
- $2 \cdot 3$ and $3 \cdot 223$;
- $3 \cdot 3$ and $2 \cdot 223$;
- $2 \cdot 3 \cdot 3$ and 223

Since $(n+m+1)-(n-m)=2 m+1>0$, $n-m$ is always the smaller of the two factors in the pair $^{1}$. Let $u=n+m+1$ and $v=n-m$, then we must be in one of the following cases:
- $v=1, u=2 \cdot 3 \cdot 3 \cdot 223$;
- $v=2, u=3 \cdot 3 \cdot 223$;
- $v=3, u=2 \cdot 3 \cdot 223$;
- $v=2 \cdot 3, u=3 \cdot 223$;
- $v=3 \cdot 3, u=2 \cdot 223$;
- $v=2 \cdot 3 \cdot 3, u=223$.[^0]

Now solving the system

$$
\left\{\begin{array}{l}
n+m+1=u \\
n-m=v
\end{array}\right.
$$

for the unknowns $n$ and $m$ we get

$$
\left\{\begin{array}{l}
n=\frac{u+v-1}{2} \\
m=\frac{u-v-1}{2}.
\end{array}\right.
$$

Note that substituting the six values of $(u, v)$ corresponding to the six possible cases into equations (5) always yields an acceptable pair of values $(n, m)$ (i.e., integers and positive: indeed, it is always $u-v>1$, and since $2 \cdot 2007$ has only one factor of 2, in all cases exactly one of $u$ and $v$ is even, and therefore $u+v-1$ and $u-v-1$ are always even). For all six of these pairs, as they were obtained, $(n+m+1)(n-m)=2 \cdot 2007$ holds, and thus all are solutions to the original equation. Moreover, the six cases presented exhaust all possibilities, so there are no other solutions. Explicitly, the solutions are:

- $n=2007, m=2006$;
- $n=1004, m=1002$;
- $n=670, m=667$;
- $n=337, m=331$;
- $n=227, m=218$;
- $n=120, m=102$

(Note, however, that the problem does not require explicitly determining the solutions, but only to state how many there are.)