5 A set $S$ of positive integers is called magic if for any two distinct members of $S, i$ and $j$,
$$
\frac{i+j}{G C D(i, j)}
$$
is also a member of $S$. The $G C D$, or greatest common divisor, of two positive integers is the largest integer that divides evenly into both of them; for example, $G C D(36,80)=4$.
Find and describe all finite magic sets.
Solution: Suppose there are two members $i$ and $j$ whose $G C D$ is 1 . Then $i+j$ is also in $S$. But $G C D(j, i+j)$ is also 1 , so $i+2 j$ is also in $S$. Continuing, $i+k j$ is in $S$ for all integers $k$, so the set is infinite.
The only remaining possibility for a finite magic set with at least two elements is that the $G C D$ of any pair of numbers in the set is greater than 1 . Now let $i$ and $j$ be the two smallest members of $S$, with $ij=i^{2}-i, n+i>i^{2}$, and $G C D(i, n) \leq i$, then $\frac{i+n}{G C D(i, n)}>i$. Any element of $S$ that is between $i$ and $n$ must equal $j$, so $\frac{i+n}{G C D(i, n)}=j$, or in other words $n=\left(i^{2}-i\right) G C D(i, n)-i$.
Since $n$ is divisible by $i, G C D(i, n)=i$ and substituting gives $n=i^{3}-i^{2}-i$. Now consider the third pair, with $j$ and $n$. Their $G C D$ is also $i$, because $j=i(i-1)$ and $n=i\left(i^{2}-i-1\right)$, and $i^{2}-i-1=(i-1) i-1$ is relatively prime to $i-1$.
Finally, $\frac{j+n}{G C D(j, n)}=\frac{\left(i^{2}-i\right)+\left(i^{3}-i^{2}-i\right)}{i}=i^{2}-2<n$, so $i^{2}-2=i$ or $i^{2}-2=j=i^{2}-i$. Both cases imply that $i=2$, from where $j=2=n$, a contradiction of our assumption that $S$ has at least two elements.
Therefore, all finite magic sets consist either of one element, or of two elements: $S=\left\{i, i^{2}-i\right\}$ for any $i \geq 3$.