Find all nonnegative integers $m$ such that

$$
a_{m}=\left(2^{2 m+1}\right)^{2}+1
$$

is divisible by at most two different primes.

Answer: $m=0,1,2$ are the only solutions.
Obviously $m=0,1,2$ are solutions as $a_{0}=5, a_{1}=65=5 \cdot 13$, and $a_{2}=1025=25 \cdot 41$. We show that these are the only solutions.

Assume that $m \geqslant 3$ and that $a_{m}$ contains at most two different prime factors. Clearly, $a_{m}=4^{2 m+1}+1$ is divisible by 5 , and

$$
a_{m}=\left(2^{2 m+1}+2^{m+1}+1\right) \cdot\left(2^{2 m+1}-2^{m+1}+1\right) \text {. }
$$

The two above factors are relatively prime as they are both odd and their difference is a power of 2 . Since both factors are larger than 1 , one of them must be a power of 5 . Hence,

$$
2^{m+1} \cdot\left(2^{m} \pm 1\right)=5^{t}-1=(5-1) \cdot\left(1+5+\cdots+5^{t-1}\right)
$$

for some positive integer $t$, where $\pm$ reads as either plus or minus. For odd $t$ the right hand side is not divisible by 8 , contradicting $m \geqslant 3$. Therefore, $t$ must be even and

$$
2^{m+1} \cdot\left(2^{m} \pm 1\right)=\left(5^{t / 2}-1\right) \cdot\left(5^{t / 2}+1\right) .
$$

Clearly, $5^{t / 2}+1 \equiv 2(\bmod 4)$. Consequently, $5^{t / 2}-1=2^{m} \cdot k$ for some odd $k$, and $5^{t / 2}+1=2^{m} \cdot k+2$ divides $2\left(2^{m} \pm 1\right)$, i.e.

$$
2^{m-1} \cdot k+1 \mid 2^{m} \pm 1 .
$$

This implies $k=1$, finally leading to a contradiction since

$$
2^{m-1}+1<2^{m} \pm 1<2\left(2^{m-1}+1\right)
$$

for $m \geqslant 3$.