Subfield: Number Theory


Question: Consider a set $S$ that contains $m \geq 4$ elements, each of which is a positive integer and no two of which are equal. We call $S$ boring if it contains four distinct integers $a, b, c, d$ such that $a+b=c+d$. We call $S$ exciting if it is not boring. For example, $\{2,4,6,8,10\}$ is boring since $4+8=2+10$. Also, $\{1,5,10,25,50\}$ is exciting.
Define $\operatorname{rem}(a, b)$ to be the remainder when the positive integer $a$ is divided by the positive integer $b$. For example, $\operatorname{rem}(10,7)=3, \operatorname{rem}(20,5)=0$, and $\operatorname{rem}(3,4)=3$. Let $n$ be a positive integer with $n \geq 10$. For each positive integer $k$ with $1 \leq k \leq$ $n$, define $x_{k}=2 n \cdot \operatorname{rem}\left(k^{2}, n\right)+k$. Determine, with proof, all positive integers $n \geq 10$ for which the set $\left\{x_{1}, x_{2}, \ldots, x_{n-1}, x_{n}\right\}$ of $n$ integers is exciting.

Solution:
Let $n$ be a positive integer with $n \geq 10$.

For each integer $k$ with $1 \leq k \leq n$, define $x_{k}=2 n \cdot \operatorname{rem}\left(k^{2}, n\right)+k$, where $\operatorname{rem}\left(k^{2}, n\right)$ is the remainder when $k^{2}$ is divided by $n$.

Define $T=\left\{x_{1}, x_{2}, \ldots, x_{n-1}, x_{n}\right\}$.

We show that $T$ is exciting exactly when $n$ is prime.

Suppose that $a, b, c, d$ are distinct integers between 1 and $n$ with $x_{a}+x_{b}=x_{c}+x_{d}$.

This equation is equivalent to

$$
\left(2 n \cdot \operatorname{rem}\left(a^{2}, n\right)+a\right)+\left(2 n \cdot \operatorname{rem}\left(b^{2}, n\right)+b\right)=\left(2 n \cdot \operatorname{rem}\left(c^{2}, n\right)+c\right)+\left(2 n \cdot \operatorname{rem}\left(d^{2}, n\right)+d\right)
$$

and

$$
2 n \cdot\left(\operatorname{rem}\left(a^{2}, n\right)+\operatorname{rem}\left(b^{2}, n\right)-\operatorname{rem}\left(c^{2}, n\right)-\operatorname{rem}\left(d^{2}, n\right)\right)=c+d-a-b
$$

Since $a, b, c, d$ are distinct integers between 1 and $n$, inclusive, then we have $1+2 \leq a+b \leq(n-1)+n$, or $3 \leq a+b \leq 2 n-1$. Similarly, $3 \leq c+d \leq 2 n-1$.



This means that $3-(2 n-1) \leq c+d-a-b \leq(2 n-1)-3$ or $-2 n+4 \leq c+d-a-b \leq 2 n-4$. But the left side of the equation

$$
2 n \cdot\left(\operatorname{rem}\left(a^{2}, n\right)+\operatorname{rem}\left(b^{2}, n\right)-\operatorname{rem}\left(c^{2}, n\right)-\operatorname{rem}\left(d^{2}, n\right)\right)=c+d-a-b
$$

is an integer that is a multiple of $2 n$, so the right side $(c+d-a-b)$ must be as well.

Since $-2 n+4 \leq c+d-a-b \leq 2 n-4$ and the only multiple of $2 n$ between $-2 n+4$ and $2 n-4$ is $0 \cdot 2 n=0$, then $c+d-a-b=0$ or $c+d=a+b$.

Thus, $2 n \cdot\left(\operatorname{rem}\left(a^{2}, n\right)+\operatorname{rem}\left(b^{2}, n\right)-\operatorname{rem}\left(c^{2}, n\right)-\operatorname{rem}\left(d^{2}, n\right)\right)=0$.

Since $n \neq 0$, then $\operatorname{rem}\left(a^{2}, n\right)+\operatorname{rem}\left(b^{2}, n\right)-\operatorname{rem}\left(c^{2}, n\right)-\operatorname{rem}\left(d^{2}, n\right)=0$.

Therefore, $x_{a}+x_{b}=x_{c}+x_{d}$ exactly when

$$
a+b=c+d \quad \text { and } \quad \operatorname{rem}\left(a^{2}, n\right)+\operatorname{rem}\left(b^{2}, n\right)=\operatorname{rem}\left(c^{2}, n\right)+\operatorname{rem}\left(d^{2}, n\right)
$$

Suppose that $n$ is composite. We show that $T$ is boring.

We consider three cases: $n=p^{2}$ for some prime $p, n$ is even, and all other $n$.

Suppose that $n=p^{2}$ for some prime $p$. Since $n \geq 10$, then $p \geq 5$.

Set $a=p, b=4 p, c=2 p$, and $d=3 p$.

Then $a+b=5 p=c+d$.

Also, since $p \geq 5$, then $0<p<2 p<3 p<4 p<p^{2}$.

Furthermore, since each of $a, b, c, d$ is divisible by $p$, then each of $a^{2}, b^{2}, c^{2}, d^{2}$ is divisible by $p^{2}=n$, so $\operatorname{rem}\left(a^{2}, n\right)=\operatorname{rem}\left(b^{2}, n\right)=\operatorname{rem}\left(c^{2}, n\right)=\operatorname{rem}\left(d^{2}, n\right)=0$.

This means that $a+b=c+d$ and $\operatorname{rem}\left(a^{2}, n\right)+\operatorname{rem}\left(b^{2}, n\right)=\operatorname{rem}\left(c^{2}, n\right)+\operatorname{rem}\left(d^{2}, n\right)$, and so $x_{a}+x_{b}=x_{c}+x_{d}$, which means that $T$ is boring.

Next, suppose that $n$ is even, say $n=2 t$ for some positive integer $t \geq 5$.

Set $a=1, b=t+2, c=2$, and $d=t+1$.

Since $t \geq 5$, then $1 \leq a<b<c<d<2 t$, so $a, b, c, d$ are distinct positive integers in the correct range.

Also, $a+b=t+3=c+d$.

To show that $x_{a}+x_{b}=x_{c}+x_{d}$, it remains to show that

$$
\operatorname{rem}\left(1^{2}, 2 t\right)+\operatorname{rem}\left((t+2)^{2}, 2 t\right)=\operatorname{rem}\left(2^{2}, 2 t\right)+\operatorname{rem}\left((t+1)^{2}, 2 t\right)
$$

Now $\operatorname{rem}\left(1^{2}, 2 t\right)=\operatorname{rem}(1,2 t)=1$ and $\operatorname{rem}\left(2^{2}, 2 t\right)=\operatorname{rem}(4,2 t)=4$ since $2 t>4$.

Also, since $(t+2)^{2}=t^{2}+4 t+4$ and so $(t+2)^{2}$ and $t^{2}+4$ differ by a multiple of $n=2 t$, then $\operatorname{rem}\left((t+2)^{2}, 2 t\right)=\operatorname{rem}\left(t^{2}+4,2 t\right)$.

Similarly, since $(t+1)^{2}=t^{2}+2 t+1$, then $\operatorname{rem}\left((t+1)^{2}, 2 t\right)=\operatorname{rem}\left(t^{2}+1,2 t\right)$.

Therefore, we need to show that $\operatorname{rem}\left(t^{2}+4,2 t\right)-\operatorname{rem}\left(t^{2}+1,2 t\right)=4-1=3$.

Since $t \geq 5$, then $t^{2}+t>t^{2}+4$.

This means that $t^{2}<t^{2}+1<t^{2}+2<t^{2}+3<t^{2}+4<t^{2}+t$; in other words, each of $t^{2}+1, t^{2}+2, t^{2}+3, t^{2}+4$ is strictly between two consecutive multiples of $t$, and so none of these four integers can be a multiple of $t$. This means that none of these is a multiple of $n=2 t$.

Therefore, $t^{2}+4$ and $t^{2}+1$ are bounded between the same two multiples of $n$, and so the difference between their remainders when dividing by $n$ equals the difference between the integers, which is 3 .

Thus, $x_{a}+x_{b}=x_{c}+x_{d}$, which means that $T$ is boring.

Finally, we consider the case where $n$ is odd and composite and can be written as $n=M N$ for some odd integers $M>N>1$.



Set $a=\frac{1}{2}(M+N), b=n-a, c=\frac{1}{2}(M-N)$, and $d=n-c$.

Since $M$ and $N$ are both odd, then $M+N$ and $M-N$ are even, and so $a, b, c, d$ are integers.

Since $M>N>0$, then $a>c>0$.

Since $N \geq 3$, then $n=M N \geq 3 M>2 M$ and so $M<\frac{1}{2} n$.

Since $M>N$, then $a=\frac{1}{2}(M+N)<\frac{1}{2}(M+M)=M<\frac{1}{2} n$.

Therefore, $0<c<a<\frac{1}{2} n$.

Since $b=n-a$ and $d=n-c$, then $\frac{1}{2} n<b<d<n$ and so $0<c<a<\frac{1}{2} n<b<d<n$. This means that $a, b, c, d$ are distinct integers in the correct range.

Also, note that $a+b=n=c+d$.

To show that $x_{a}+x_{b}=x_{c}+x_{d}$, it remains to show that

$$
\operatorname{rem}\left(a^{2}, n\right)+\operatorname{rem}\left(b^{2}, n\right)=\operatorname{rem}\left(c^{2}, n\right)+\operatorname{rem}\left(d^{2}, n\right)
$$

We show that $\operatorname{rem}\left(a^{2}, n\right)=\operatorname{rem}\left(b^{2}, n\right)=\operatorname{rem}\left(c^{2}, n\right)=\operatorname{rem}\left(d^{2}, n\right)$, which will provide the desired conclusion.

Since $b=n-a$, then $b^{2}=n^{2}-2 n a+a^{2}$. Since $b^{2}$ and $a^{2}$ differ by a multiple of $n$, their remainders after division by $n$ will be equal. Similarly, $\operatorname{rem}\left(c^{2}, n\right)=\operatorname{rem}\left(d^{2}, n\right)$.

Thus, it remains to show that $\operatorname{rem}\left(a^{2}, n\right)=\operatorname{rem}\left(c^{2}, n\right)$.

But

$$
a^{2}-c^{2}=(a+c)(a-c)=\left(\frac{1}{2}(M+N)+\frac{1}{2}(M-N)\right)\left(\frac{1}{2}(M+N)-\frac{1}{2}(M-N)\right)=M N=n
$$

Since $a^{2}$ and $c^{2}$ differ by a multiple of $n$, then $\operatorname{rem}\left(a^{2}, n\right)=\operatorname{rem}\left(c^{2}, n\right)$.

Thus, $x_{a}+x_{b}=x_{c}+x_{d}$, which means that $T$ is boring.

Suppose that $n$ is prime. We show that $T$ is exciting.

Since $n \geq 10$, then $n$ is odd.

Suppose that $x_{a}+x_{b}=x_{c}+x_{d}$. We will show that this is not possible.

Recall that $x_{a}+x_{b}=x_{c}+x_{d}$ is equivalent to the conditions $a+b=c+d$ and $\operatorname{rem}\left(a^{2}, n\right)+$ $\operatorname{rem}\left(b^{2}, n\right)=\operatorname{rem}\left(c^{2}, n\right)+\operatorname{rem}\left(d^{2}, n\right)$.

We work with this second equation.

When $a^{2}$ is divided by $n$, we obtain a quotient that we call $q_{a}$ and the remainder $\operatorname{rem}\left(a^{2}, n\right)$. Note that $a^{2}=q_{a} n+\operatorname{rem}\left(a^{2}, n\right)$ and $0 \leq \operatorname{rem}\left(a^{2}, n\right)<n$.

We define $q_{b}, q_{c}, q_{d}$ similarly and obtain

$$
\left(a^{2}-q_{a} n\right)+\left(b^{2}-q_{b} n\right)=\left(c^{2}-q_{c} n\right)+\left(d^{2}-q_{d} n\right)
$$

or

$$
a^{2}+b^{2}-c^{2}-d^{2}=n\left(q_{a}+q_{b}-q_{c}-q_{d}\right)
$$

Since $a+b=c+d$, then $a^{2}+2 a b+b^{2}=c^{2}+2 c d+d^{2}$ or $a^{2}+b^{2}-c^{2}-d^{2}=2 c d-2 a b$.

Therefore, $x_{a}+x_{b}=x_{c}+x_{d}$ exactly when $a+b=c+d$ and $2 c d-2 a b=n\left(q_{a}+q_{b}-q_{c}-q_{d}\right)$. Since $d=a+b-c$, then this last equation becomes

$$
\begin{aligned}
2 c(a+b-c)-2 a b & =n\left(q_{a}+q_{b}-q_{c}-q_{d}\right) \\
-2\left(c^{2}-a c-b c+a b\right) & =n\left(q_{a}+q_{b}-q_{c}-q_{d}\right) \\
-2(c(c-a)-b(c-a)) & =n\left(q_{a}+q_{b}-q_{c}-q_{d}\right) \\
-2(c-a)(c-b) & =n\left(q_{a}+q_{b}-q_{c}-q_{d}\right)
\end{aligned}
$$

Since $x_{a}+x_{b}=x_{c}+x_{d}$, then $a+b=c+d$ and $-2(c-a)(c-b)=n\left(q_{a}+q_{b}-q_{c}-q_{d}\right)$. Therefore, $2(c-a)(c-b)$ is a multiple of $n$, which is an odd prime.



This means that either $c-a$ or $c-b$ is a multiple of $n$.

But $a, b, c, d$ are between 1 and $n$ inclusive and are distinct, so $1-n \leq c-a \leq n-1$ and $1-n \leq c-b \leq n-1$.

The only multiple of $n$ in this range is 0 , so $c-a=0$ or $c-b=0$, which contradicts the fact that $a, b, c, d$ are distinct.

Therefore, if $n$ is prime, there do not exist four distinct elements of $T$ that make $T$ boring, so $T$ is exciting.

In summary, $T$ is exciting exactly when $n \geq 10$ is prime.

Final answer: exactly when $n \geq 10$ is prime