Problem: Let $S$ be the set of all positive integers $n$ such that $n^4$ has a divisor
in the range $n^2 + 1$, $n^2+2$, \dots, $n^2 + 2n$.
Prove that there are infinitely many elements of $S$ of
each of the forms $7m$, $7m+1$, $7m+2$, $7m+5$, $7m+6$
and no elements of $S$ of the form $7m+3$ and $7m+4$,
where $m$ is an integer.

\end{enumerate}

Solution: Start from the implication
\[ n^2 + k \mid n^4 \iff n^2 + k \mid k^2. \]
Since $1 \le k \le 2n$, in fact the quotient $\frac{k^2}{n^2+k}$
can only take values from $1$ to $3$.
In other words, $S$ is the set of integers $n$ for which at least one equation
\begin{align*}
  n^2 + k &= k^2 \\
  2(n^2 + k) &= k^2 \\
  3(n^2 + k) &= k^2
\end{align*}
has at least one solution $1 \le k \le 2n$.

The first equation has no solutions with $k \ge 1$
since we can put $(k-1)^2 < n^2 < k^2$.
The other two are Pell equations,
and one can check that $n^2 \equiv 2 \pmod 7$ has no solutions at all
for $k \pmod 7$ in either case.
The assertion about infinitely many solutions then follows by
using the Pell recursion, and taking modulo $7$.