TITLE: $a^b+2$ or $a^b-2$ is in set
QUESTION [14 upvotes]: Let $A$ be an infinite set of positive integers. For any two $a,b\in A$, $a\neq b$, at least one of the numbers $a^b+2$ and $a^b-2$ are also  in $A$. Must $A$ contain a composite number?

REPLY [11 votes]: The answer is yes. 
Take four odd numbers $a<b<c<d$ from the set, all greater than $3$, such that $c=b^a\pm2$ and $d=c^b\pm2$.
Case 1: $c=b^a\pm2$ and $d=c^b\pm2$ (with equal signs).
Then $c=b^a\pm2\equiv b\pm2 \pmod3$ and $d=c^b\pm2\equiv c\pm2 \pmod3$. One of $b,c,d$ is divisible by $3$.
Case 2: $c=b^a\pm2$ and $d=c^b\mp2$ (with opposite signs).
If $b$ is a prime then, by Fermat's theorem,
$$
d = c^b \mp2 \equiv c\mp2 = b^a \equiv 0 \pmod{b}
$$
so $d$ is divisible by $b$. (Obviously $d$ is greater than $b$.)