Task 2. Find all integers $n$ for which $\frac{4 n-2}{n+5}$ is the square of a rational number. (A rational number is a number in $\mathbb{Q}$.)
Solution. Suppose $\frac{4 n-2}{n+5}$ is the square of a rational number. Then we can write it as $\frac{p^{2}}{q^{2}}$ with $p, q$ non-negative integers, $q \neq 0$ and $\operatorname{gcd}(p, q)=1$. Due to the condition $\operatorname{gcd}(p, q)=1$, $\frac{p^{2}}{q^{2}}$ is the most simplified version of this fraction, so there is an integer $c \neq 0$ such that $4 n-2=c p^{2}$ and $n+5=c q^{2}$. Now we have

$$
22=4(n+5)-(4 n-2)=4 c q^{2}-c p^{2}=c\left((2 q)^{2}-p^{2}\right)=c(2 q-p)(2 q+p) .
$$

So $c$ is a divisor of 22. Furthermore, 22 is divisible by 2, so the right-hand side is also divisible by 2. If there is a factor of 2 in $2 q-p$, there is also a factor of 2 in $2 q+p$, because these two factors differ by $2 p$ and that is even. Conversely, if $2 q+p$ is divisible by 2, then $2 q-p$ is also divisible by 2. But 22 contains only one factor of 2, so it cannot be that both $2 q-p$ and $2 q+p$ are divisible by 2. We conclude that $2 q-p$ and $2 q+p$ are precisely odd, and $c$ is therefore even. Finally, since $p \geq 0$ and $q \geq 1$, we have $2 q+p \geq 2$, so the factor 11 from 22 must be in $2 q+p$. We conclude that there are only two possibilities:

- $c=2,2 q+p=11,2 q-p=1$;
- $c=-2,2 q+p=11,2 q-p=-1$.

In the first case, we find $2 p=11-1=10$, so $p=5$ and $q=3$. This gives $4 n-2=50$, so $n=13$. Checking: $\frac{4 n-2}{n+5}=\frac{50}{18}=\frac{25}{9}=\frac{5^{2}}{3^{2}}$, so $n=13$ indeed satisfies. In the second case, we find $2 p=11--1=12$, so $p=6$, but then $q$ cannot be an integer anymore, so this case is invalid. We conclude that there is exactly one solution, and that is $n=13$.