TITLE: $4k^2+n$ is prime
QUESTION [8 upvotes]: Find all $n$ positive integers such that $4k^2+n$ is prime for every nonnegative integer  $k$ less than $n$
My progress $k=0$ we get $n$ is a prime number
let $k=n-l$ we get $n+4n^2+4l^2-8nl$ is a prime number
which means $l$ doesn't divide $n(4n+1)$ since $n$ is prime
$l$ doesn't divide $(4n+1)$ for every $l$ less than $n$
so suppose $4n+1=ab \leq n^2, a,b \gt 1, n(n-4) \leq 1$ this gives $4$ values still have not tried them
other than that we get $4n+1$ is prime
if $n \equiv 1 \pmod 4$ then $4(\frac{n-1}{4})^2+n = (\frac{n+1}{2})^2$
contradiction so whats left is $n=3 mod 4$

REPLY [4 votes]: Note $n$ must be an odd integer so $n \equiv 1, 3 \pmod{4}$. As you already stated, for primes $n \equiv 1 \pmod{4} \implies n = 4j + 1, \; j \in \mathbb{N}$, then $k = j$ gives
$$4j^2 + 4j + 1 = (2j + 1)^2 \tag{1}\label{eq1A}$$
As $n \gt 1 \implies j \gt 0$, this is not a prime. Thus, this only leaves $n \equiv 3 \pmod{4}$. As Robert Shore's question comment stated, $n = 3$ works, and as I stated, $n = 7$ also works.
For primes $n \gt 7$, first consider $n \equiv 3 \pmod{8} \implies n = 8j + 3, \; j \in \mathbb{N}$. Then $k = j$ gives
$$4j^2 + 8j + 3 = (2j + 3)(2j + 1) \tag{2}\label{eq2A}$$
Since $j \gt 0$, this is not prime. This leaves checking $n \equiv 7 \pmod{8}$, with it being done in $2$ parts. First, $n \equiv 7 \pmod{16} \implies n = 16j + 7, \; j \in \mathbb{N}$. Here, $k = j$ gives
$$4j^2 + 16j + 7 = (2j + 1)(2j + 7) \tag{3}\label{eq3A}$$
As $j \gt 0$, this is not prime. Second, $n \equiv 15 \pmod{16} \implies n = 16j + 15, \; j \in \mathbb{N}$. Using $k = j$ gives
$$4j^2 + 16j + 15 = (2j + 3)(2j + 5) \tag{4}\label{eq4A}$$
with this also not being prime.
Since all of the remaining possibilities for odd prime integers $n$ have been covered, this shows $n = 3, 7$ are the only solutions.