We define the sequence $a_n=(2n)^2+1$ for each natural number $n$. We will call one number bad, if there don’t exist natural numbers $a>1$ and $b>1$ such that $a_n=a^2+b^2$. Prove that the natural number $n$ is bad, if and only if $a_n$ is prime.
Problem
Source: X International Festival of Young Mathematicians Sozopol 2019, Theme for 10-12 grade
Tags: number theory, Sequence, prime numbers