2. Find all primes $p$ such that $\frac{2^{p+1}-4}{p}$ is a perfect square.
Solution. Note that the given equation can be rewritten as follows.
$$
\frac{2^{p+1}-4}{p}=4 n^{2} \Longrightarrow \frac{2^{p-1}-1}{p}=n^{2} \text {. }
$$

Note that if $p=2$, the only even prime number, then $\frac{2^{p-1}-1}{p}=\frac{1}{2}$, which is not a square of an integer. Thus, $p$ must be odd, and so, $p-1$ is even, which means we can factor the numerator because it is a difference of two squares. Hence,
$$
\frac{2^{p-1}-1}{p}=\frac{\left(2^{\frac{p-1}{2}}-1\right)\left(2^{\frac{p-1}{2}}+1\right)}{p} .
$$

We note that the two factors in the numerator differ by 2 and each factor is odd. Thus,
$$
\operatorname{gcd}\left(2^{\frac{p-1}{2}}-1,2^{\frac{p-1}{2}}+1\right)=1 \text {. }
$$

This implies that
$$
\operatorname{gcd}\left(2^{\frac{p-1}{2}}-1, \frac{2^{\frac{p-1}{2}}+1}{p}\right)=\operatorname{gcd}\left(2^{\frac{p-1}{2}}+1, \frac{2^{\frac{p-1}{2}}-1}{p}\right)=1 .
$$

Since we also have $\frac{\left(2^{\frac{p-1}{2}}+1\right)}{p}\left(2^{\frac{p-1}{2}}-1\right)=n^{2}$, then both $\frac{\left(2^{\frac{p-1}{2}}+1\right)}{p}$ and $\left(2^{\frac{p-1}{2}}-1\right)$ or both $\frac{\left(2^{\frac{p-1}{2}}-1\right)}{p}$ and $\left(2^{\frac{p-1}{2}}+1\right)$ must be perfect squares.
Case 1: Let $2^{\frac{p-1}{2}}-1=x^{2}$, where $x=2 q+1$ with $q \in \mathbb{Z}$. Then
$$
2^{\frac{p-1}{2}}-1=(2 q+1)^{2}=4 q^{2}+4 q+1=4 q(q+1)+1 \Longrightarrow 2^{\frac{p-1}{2}}-2=4 q(q+1) .
$$

If $\frac{p-1}{2} \geq 2$, then $2^{\frac{p-1}{2}}$ will be divisible by 4 , but $2^{\frac{p-1}{2}}-2$ will be $2(\bmod 4)$, which is a contradiction. Thus, $\frac{p-1}{2}1$, then $r$ or $r+1$ is an odd number, which means $4 r(r+1)$ has an odd divisor, but $2^{\frac{p-1}{2}}$ is even for all $p \geq 3$. Thus, $r=1$ is the only possible case. Hence, we have
$$
2^{\frac{p-1}{2}}=4(1)(2)=8 \Longrightarrow \frac{p-1}{2}=3 \Longrightarrow p=7 \text {. }
$$

If $p=7$, then $\frac{2^{p-1}-1}{p}=9$, which is a perfect square.
Since we have exhausted all possible cases, then $p=3,7$ are the only possible values of p.