Exercise 7. Let $n \geqslant 1$ be an integer. Find all divisors $d \geqslant 1$ of $3 n^{2}$ such that $n^{2}+d$ is a perfect square.
Solution to Exercise 7: Let $d \geqslant 1$ be a divisor of $3 n^{2}$ such that $n^{2}+d$ is a perfect square. Since $n^{2}<n^{2}+d \leq n^{2}+3 n^{2}=(2 n)^{2}$, there exists $k \in \llbracket 1, n \rrbracket$ such that $n^{2}+d=(n+k)^{2}$. Simplifying, we get $d=2 k n+k^{2}$, so $k(k+2 n) \mid 3 n^{2}$.

Let $\alpha=\operatorname{gcd}(k, n) \geqslant 1$. There exist integers $\ell, m \geqslant 1$ that are coprime such that $k=\alpha l$, $n=\alpha m$. The divisibility relation then becomes, after simplification, $\ell(\ell+2 m) \mid 3 m^{2}$. Since $\operatorname{gcd}(\ell+2 m, m)=\operatorname{gcd}(\ell+2 m-2 m, m)=\operatorname{gcd}(\ell, m)=1$, that is, $\ell+2 m$ is coprime with $m$, and thus with $m^{2}$. Since $\ell+2 m \mid 3 m^{2}$, by Gauss's lemma, $\ell+2 m \mid 3$, that is, $\ell+2 m \in\{1,3\}$. But $\ell, m \geqslant 1$ so $\ell+2 m \geqslant 3$. In other words, $\ell+2 m=3$ and thus necessarily, $\ell=m=1$. Then $k=n=\alpha$, and $d=k(k+2 n)=3 n^{2}$.

Conversely, $d=3 n^{2}$ works since it is a divisor of $3 n^{2}$ and $n^{2}+3 n^{2}=(2 n)^{2}$.

Graders' Comments: The exercise is not well addressed. All copies have the correct intuition of the unique solution. Other proofs than the one in the solution have been proposed by students (they notably use the parity of $p$-adic valuations for $p$ prime and finding the $m$ such that $\frac{m+3}{m}$ is a square of a rational number).